Or is it more if you lived even like 500 meters of a border do you learn the language of the country your in?
That tends to be how it’s done. States tend to be rather protective of their official language, and it’s generally impractical to send your children to school in a different country. Being somewhat proficient in the other country’s language is quite common, but to truly be bilingual you pretty much need to be some kind of ethnic or religious minority.
Also depends a lot on the relationship between the countries and languages; some borders are easier to cross, and some languages easier to learn.
German is actually a fairly popular foreign language in countries east of Germany: https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Foreign_language_learning_statistics#Upper_secondary_education
Though learning a second or third language in school is probably not quite what OP envisions here, and there’s a big difference between getting language lessons in school and actually being able to speak that language (shoutout to my Spanish lessons in school, I should probably have picked French instead).