Fairly common as easy to knock when dropping wheels out etc. Couple of havks that work for me.
1)put the wheel in, do up quick release, turn the pedals a few times so the gears settle on the correct sprocket. Open Qr, close QR. If the mech is in the wrong gear for where the chain is, the tension can push the wheel out of alignment.
2) Put wheel in, do up QR and Brake QR. Undo wheel QR, squeeze break lever then do up wheel QR without releasing the lever.
Finally, an my most common, if you’re sure your wheel is centred, just gently hold the calliper on both pads and push/pull to centre. Bonus of rim brakes IME, so easy to centre, even when out, no need for tools. They’re only held on by one bolt, so a degree of easy movement each way.
Another point, make sure you’re undoing the QR on the brake when dropping wheels out, less chance of dragging the wheel past the pads and knocking it