The Leaning Tower of Pisa wasn’t supposed to lean at all. It was supposed to just be the bell tower for the Cathedral of Pisa. It was to hold the bells that rang to tell people when to come to church. But they built the tower in the Early Middle Ages, about 1173 AD. Nobody in Europe had been building anything much for several hundred years. So the architects were not really experienced.
This tower looks like the bell tower from the Romanesque church at Toulouse almost 200 years earlier, but it stands alone instead of on top of the church. The architects were probably imitating Islamic minarets from across the Mediterranean Sea, but they didn’t really know what they were doing. (and those minarets, in turn, may have been inspired by Chinese Buddhist pagodas.)
So the architects built their bell tower on soft ground, without enough foundations. And as soon as they were done the tower began to slowly tilt over sideways. But very slowly.
Even today, the tower is still tilting over, little by little. Though mostly engineers have stopped it now with reinforcements to make it stronger.