I'll explain the B757 for you. There is a truck positioner actuator located on the aft part of the gear. When weight is off the wheels, hydraulic pressure positions the actuator to extend and drive the aft wheels down. Now the purpose as the Aircraft manual states is to permit clearance between the gear and aircraft structure during gear retraction and extension. But I remember an instructor once telling me that they testes a B767-200 some time ago to see if it would clear the structure if not tilted. He said it did. (The B767 has the actuator on the front part of the bogie and the forward wheels go down.).
I also remember another incident at my airline a couple of years ago. And aircraft had to do an air return due to the landing gear lever lock solenoid not releasing after the aircraft transitioned to air mode. Now, I believe the crew pushed the lever lock override button and raised the gear. I mention this because when the aircraft was troubleshot, it was found that there was a hydraulic leak upstream of the truck positioner actuator and the wheels were sort of dangling, meaning that you could tilt them with your hands up and down. There was no hydraulic pressure to position the gear. Maybe the gear just happened to be in the correct position when they retracted the gear that time, because there were no problems.
So the gears are tilted to allow for clearance into the gear (official reason), and a secondary function is to provide air/gnd mode logic, since sensors depend of gear angle and wows (This applies to the B757/B767/B777).
As for you other question as to when this happens. On the B757/B67, the gears are tilted whenever weight is off the wheels. The gears are always tilted. The B777 is different. The rear wheels are tilted downward for ldg (unless there is a high approach angle. At that point the gear will actually adjust to help compensate for a steep ladg angle) and the rear wheels are tilted up during retraction. The can only fit into the wheelwell this way.
Hope this helps, I need water now!
PS...Maybe someone can shed some light on Airbus. I'm going to ASS-U-ME it works in a similar manner on the A300/10/30/40. But u know what happens when you ASS-U-ME