HSA Account with Medicare Part A

I thought you had to apply for Medicare Plan A 3 months before your 65th birthday.  So I did so I wouldn't get penalized (or so I though).  I work FULL-TIME and get medical insurance and HSA account of which I contribute $30 a paycheck.  I learned just last night, totally by accident, that I can't have an HSA with Medicare Plan A.  NEWS TO ME!  I was also told that I didn't have to sign up for Medicare Plan A at age 65.  I could wait until i actually RETIRE and no longer have my company insurance.  That I can reapply and show the 1095C form that I have had insurance.   So I find out that my HSA will be penalized for any money in there that I have contributed.  The 6% penalty isn't that much, but are you being taxed on the total amount in the account , or just penalized on the NEW contributions you make each year.  Meaning is I have $1,000 rollover, the next year i contribute $500 - am I being penalized on the $500 or the total $1,500?  So confusing!