If it's a cartridge razor, those are allowed in your carry-on. *Aerosols larger than 3.4 oz are not, so that might
explain why.
If it's a legit razor then yea, TSA dropped the ball. But the aerosol can stuff is consistently enforced.
Edit: added right aerosol restriction