@Distela,
I had this issue with my daughter bed in her dorm. I am assuming the the bed are stack on top of each other? What I did was use two ratcheting straps. Each one going from the top of one bed to the bottom of the opposite end of the lower bed. the result was a X on the long side of the bed where is was against the wall. That helped a lot but was not that pretty. Could do something similar with steel cables and turnbuckles.
If the setup was acceptable at some point, I would consider taking the bed apart and fixing it the right way. I didn't have that option since these were dorm beds.