But, what happens if an astronaut has a medical emergency? Does NASA return just the astronaut with the medical emergency (leaving the station without a lifeboat) or do all six come home leaving the station unoccupied?
That is one of the reasons for the crew swap. One crew would return on their lifeboat with the ill person, and the other crew with the ride swap person would be able to keep the station going.
There are normally seven crew on board ISS, four US (one rode on Soyuz) and three Russian (one rode on Drahon). Currently there are two extra that rode on Starliner. In the event of a medical emergency, only one of the Soyuz or Dragon needs to return with its crew. (A change in crew swap could also be possible, perhaps.)