This is what is referred to in the Qur'an as Allah sealing people's hearts (e.g. 2:7); i.e. they have gone so far towards evil that they have lost the capability to change.
However, this does not happen if we just make a mistake or do something wrong; rather, it is for people like Yazid.
A person with their heart sealed might do something that, on the surface, appears to be a good act, but would lack the inner intention for it to genuinely be classified as one in the hereafter.