Unlike the knees, the hips don't really "lock" - upright femurs are the limit of range of motion of the knees, but an upright torso is not the limit of the range of motion of the hips. So the idea that it is crucial to "lock" the hips doesn't make sense.
Powerlifting rules are usually simply that in the squat, the lifter must return to an upright posture with the knees locked. Depending on the bar weight and position, this often requires a slight forward lean (particularly with a low-bar position), so you can't really specify a required hip angle.
This only really matters for competition though, as the top of a squat is by far the easiest part of the lift, so a lifter who, outside of powerlifting competition, does not fully lock out their knees or return to a fully upright torso is not going to be any worse off.
in deadlift, my final position is reached by squeezing my glutes and pushing my hips slightly forward
This sort of hyperextension is usually regarded as bad form in the deadlift, and is not required for competition. Powerlifting rules are usually that the deadlift is complete when the lifter is standing upright with knees locked and shoulders back. So a failure to "lock out" the deadlift usually means either slightly flexed knees, or shoulder/upper back rolled forward, not anything to do with hip position.
Why can't this be done in squat?
Because the bar would fall off your shoulders if you pushed your hips forward.