Airplanes in the air, like ships at sea, operate under the rules and regulations of their "flag" country. Imagine if you had to have maintainance logs (for example) which comply with differing standards in each country where you wanted to land.
This is why many ships are flagged in Panama or Liberia or whatever to take advantage of the lax regulations. Doesn't work for airplanes though since most only fly to/from their home country and the Panama-Liberia market isn't so big

If the aviation regulations of a country aren't up to some minimum standard, their planes may be refused landing in other countries.
Michael