The wheel shifting while riding as you describe is a common symptom of a QR skewer that isn't tight enough. Or of one that's not getting enough "bite" into the dropout face, particularly if your bike has horizontal dropouts like a single-speed or track bike.