English has all sorts of ambiguities like this. (I suspect most other languages do too.) Usually the correct meaning is clear from context. If not, you have to rewrite the sentence, sometimes drastically.
"My favorite sport is swimming" is unlikely to cause confusion. It's hard to see how a sport can swim, so it's pretty obvious that the gerund is intended.
tchrist did come up with a couple of sentences where it might truly be ambiguous. "My favorite sport is boring my wife." The writer could mean that the sport that he most enjoys is not interesting to his wife, like he enjoys watching football but she thinks that football is boring. Or he could mean that the thing he mosts likes to do is to make his wife feel bored, that they often have conversations where he drones on for hours about subjects that do not interest her. The second meaning is likely a joke or a sarcastic comment, but it is a plausible interpretation of the sentence. (This is the kind of ambiguity that is the basis for many jokes.)
The intended meaning would often be made clear from the larger context. Like if you said, "I really love football. I spend hours a day watching it on TV and reading about it. But my wife hates it. My favorite sport is boring my wife." Then the first meaning is likely intended. But, "My marriage has sunk into a dull sameness. The only pleasure I get these days is the victory of knowing that I am making her even more depressed than I am. My favorite sport is boring my wife." In that the second meaning is meant.
You could reword the sentence to eliminate the ambiguity. Like, "My wife finds my favorite sport boring" versus "Boring my wife is my favorite sport."