Greendrake's answer says that a country can declare any jurisdiction it likes. This is true, but in practice it is the convention that a country should claim jurisdiction only over its territory and its citizens. The point about "citizens" is normally not pushed, as when you go to a foreign country you are normally subject to its laws rather than those of your home, but for instance there are laws against child sex tourism where the perpetrators can be prosecuted at home for offences committed abroad.
However this basic principle gets more murky with long-distance communication such as the Internet. Someone in country X can, for example, provide a service to someone in country Y which is illegal in country Y. At this point the laws of country Y have been broken by someone sitting in country X. Y is not claiming extraterritorial jurisdiction; the crime occurred inside its own territory, but the criminal is currently resident in X. From a legal point of view this is the same as if both had been inside Y when the crime was committed, but then the perpetrator fled to X before they could be arrested.
So in the Kim Dotcom case, Dotcom is alleged to have committed criminal copyright violations by supplying movie files to people in the US.
In the Meng Wanzhou case, Meng is alleged to have made fraudulent statements to American banks to the effect that Huawei was complying with US sanctions law (otherwise those banks would not have been able to do business with Huawei). The accounts I've read don't say whether Meng was in the US for those meetings, but the fact that they were made to American banks in order to do business in America makes the precise location of the meeting irrelevant.