Does higher hardness means that A cannot scratch B regardless of any other variable?
Welcome.

You're referring to the Mohs hardness scale, a qualitative scale to quickly determine, in the field, whether something scratches (carves a mark into) something else. It states nothing about the opposite direction. Of course, given enough pressure or kinetic energy the scraper can experience deformation as well, but that's not the meaning of the exercise.

One can pretty well scratch Gypsum with the finger nail and feldspar with a steel nail. You don't hammer things and do not scratch over and again or with more force than necessary. It's more like, for instance, cutting wood with a pocket knife. No molecules are counted and no microscopic traces investigated, it is just a superficial visual inspection for use in the field. Laboratory work comes later.

https://geology.com/minerals/mohs-hardness-scale.shtml

https://en.wikipedia.org/wiki/Mohs_scale_of_mineral_hardness

https://www.nps.gov/articles/mohs-hardness-scale.htm

Edit: To make some sciency disport out of this, here's a work that deals with the force of a large cat's claws and muscles against the bones of its prey.

Even though the claw, being made of keratin (same as horn, hoove, nail, ...), only has a Mohs hardness of 2.5, it can do considerable damage to a bone of hardness 5. That's because of the kinetic energy induced by the sweep of a paw and the chain of muscles at whose end it sits.

The field test based on Mohs hardness is not affected by the application of kinetic energy.