One of two reasons.
They're set on Earth, which is a place where people often talk in different languages.
They're not set on Earth, but somewhere else that shares this feature with Earth.
More specifically than that, there can be a variety of reasons. The most direct is verisimilitude. Taking the two points again, the creators decided to be realistic in this regard. Consider the cases you raise yourself:
One huge scene that comes to mind is when Jackie Chan goes to the church. The priest asks him if he's Japanese (in English) and Chan says he's Korean (again in English).
So the priest does not know what nationality Chan is. They're in Hong Kong (Cantonese and English are the official languages with 88% speaking Cantonese and 5% speaking English) and the priest thinks he is Japanese (both Cantonese and English are possible, but English is a good bet). Picking English as the language to speak this in seems reasonable.
Then they start speaking Korean. Why not just stick to English?
Chan replies that he's Korean. He does so in English because clearly the priest speaks English.
The priest now knows that there's an extremely high chance that Chan speaks Korean. The priest also knows that the priest speaks Korean (duh). Switching to Korean is natural, and polite.
Also, he has certain conversations with a lawyer in both English and Korean, depending on the scene.
So they're code-switching just like people do in real life.
There's also one Korean woman he speaks to only in English.
So they're deciding to code-switch or not with different people in different contexts at different times. Again, just like in real life.
Of course, they could have also been realistic if they only every spoke Korean and Cantonese, but there are commercial advantages in mainly using English. They could have been reasonably realistic if everybody just spoke English either because it was plausible in the context or as a willing suspension of disbelief in which English is used to represent speech in other languages (nobody complains much that English is used to represent Basic in Star Wars or Westron in Lord of the Rings, never mind it representing a lot of real languages in many films) but having a bit of other languages is one way to give a realistic flavour.
There are other reasons why one might use other languages such as (not exhaustive):
- World-building verisimilitude. Akin to the above, but instead of being realistic in relation to what really happens is being realistic in relation to an artificial world. Again Star Wars and Lord of the Rings are examples; Basic and Westron are represented by using English, but other languages are used to give a sense of a multilingual environment.
- To make something deliberately unintelligible to the audience, one or more characters, or both, so information remains hidden (if perhaps only for a while).
- As above, but to emphasise a character's state of confusion (think of Bill Murray's character at the start of Lost in Translation).
- To play games with meaning, such as the way much was made of convenient and appropriate being expressed with the same word in Russian in The Russia House (which just did that in English, but that's the best example I can think of right now).
Really if anything the opposite question should be asked: Why do many movies remain solely in English in cases where it is implausible or unlikely that the characters speak English. In most cases it's just a sustained conceit that e.g. in Les Miserables we know everyone is speaking French all the time, and English is used to represent that. That works well enough when everyone would be expected to understand each other's language. Sci-fi and fantasy often has to come up with magic/high-tech solutions (Doctor Who and Star Trek both have universal translation that only fails to work when it suits the plot) or just hand-wave it. Or jokingly point out how stupidly unrealistic it is and move on ("How do you know English?" "How do you know Asgardian?").