As I understand Oyster cards, you swipe them on the station you enter, and the station you leave
This is normally the case for train/tube/DLR travel on oyster. Buses and trams have other arrangements. Also oyster cards are based on NFC, not magstripes so it's more of a tap than a swipe.
As in you don't swipe them when changing underground lines (maybe you do on some stations though?).
Normally touching out ends your journey and if you touch back in you will be charged for a separate journey (subject to daily capping).
However there are a number of locations on the network where "out of station interchanges" are allowed allowing you to touch out and touch back in to a nearby station or to a different part of the same station without ending your journey.
So if there is a variety of ways you could have gotten between A and B and one is more expensive, what are you charged?
Ultimately the system looks at what readers/gatelines you used and makes assumptions based on that. The normal assumption is that you took the fastest/most direct route that is consistent with the readers you used.
The zonal fares system means that the exact route you took is not usually a massive issue, the main exception to this is if you want to save money by taking a route that avoids zone 1. In such cases you should look your journey up on the tfl "single fare finder" and use a pink validator if needed.
National rail services that take oyster but are not run by TFL (and the Heathrow branch of TFL rail) can also have higher fares than underground services. This is mostly handled by splitting stations into areas with separate gate-lines, though the system does have some flaws.
(I've heard something about pink validators?)
Yes, some stations have pink validators. You touch your card on these when interchanging to tell the system where you changed trains. The "single fare finder" will tell you when and where you need to use them.
Note: when using the single fare finder be careful what station you select. In particular the rail and underground parts of a station are often considered to be seperate stations by the fare finder.