Let's assume you are 10 feet away from your friend Joe and take his picture in portrait orientation with a 50mm lens. Say there is a building 100 feet behind Joe. The building is 10X the distance from the camera as Joe is, so if Joe is 6 feet tall and the building is 60 feet tall they will appear to be the same height in your photo, because both would occupy about 33º of the 40º angle of view of a 50mm lens along the longer dimension.
Now back up 30 feet and use a 200mm lens. Your total distance from Joe is now 40 feet. Since you are using a focal length that is 4X the original 50mm (50mm X 4 = 200mm), he will appear the same height in the second photo as he did in the first. The building, on the other hand, is now 130 feet from the camera. That is only 1.3X as far as it was in the first shot (100ft X 1.3 = 130ft), but you have increased the focal length by 4X. Now the 60 foot tall building will appear to be roughly 3X the height of Joe in the picture (100ft / 130ft = 0.77; 0.77 X 4 = 3.08).
Another way to look at it is that in the first photo with the 50mm lens, the building was 10X further away than Joe was (100ft / 10ft = 10). In the second photo with the 200mm lens, the building was only 3.25X further away than Joe was (130ft / 40ft = 3.25), even though the distance between Joe and the building was the same. What changed was the ratio of the distance from the camera to Joe and the distance of the camera to the building. That is what defines perspective: The ratio of the distances between the camera and various elements of a scene.