Getting the rear wheel to sit flush against both chain adjusters while tightening the axle nut can be difficult. Just as described, it's common for the axle to slide in the swingarm as you attempt to tighten the nut-even holding your knee against the wheel doesn't always work.
But there's a simple trick that makes life easier; just slip a screwdriver (or the like) in between the teeth of the rear sprocket and the chain, then spin the screwdriver up between the two until it preloads the wheel against the chain adjusters. Tighten the axle nut and spin the wheel backwards to release the screwdriver.
The screwdriver temporarily increases the chain tension enough to preload the wheel against both adjusters, making it easy to tighten the nut while ensuring the wheel is straight.
Make sure to feed the screwdriver between the teeth as shown in the smaller picture though, since damaging the teeth on your sprocket can be an expensive mistake.