Put the bike on the ground, wheels down, and lean on the saddle/handlebar when you are tightening the bolt for the rear/front skewer. Your body weight will ensure that the hub axles are in the right place, and keep the skewer from wandering. Also, put some grease in the socket that the long skewer/bolt is recessed in, which will reduce the tendency for it to walk while tightening it.