How to loosen a nut when bolt and nut move together?
Best way: put a wrench on the nut and the proper driver or socket into or over the head of the bolt, and turn one while keeping the other stationary.

Second best way: put a wrench on the nut, and a pair of locking pliers on the shank of the bolt. You WILL damage the threads of the bolt; just try not to cause so much damage the nut won't come off. This is the only way besides cutting to remove a carriage bolt, which has a flat or a smooth dome head that can't be "locked on" with a socket or driver, or to otherwise remove a nut from a bolt when you can't get to the head.