Ownership and immigration status usually run on separate tracks. Buying property in most countries neither grants nor strengthens a visa application by itself, though it can help indirectly as evidence of ties, accommodation, and financial standing in some residency processes. The clear exception is countries with investor or golden visa programs, where a property purchase above a defined threshold is a formal residency route; these programs change frequently, so check the current official position before planning around one.
On the flip side, if your residency ends, you almost always retain full legal ownership and can sell or rent the property from abroad. What changes is practical: you may face non-resident tax rates on rental income and capital gains, restrictions on local financing, and the hassle of remote management.
A small number of jurisdictions restrict certain property types to residents, in which case losing status can force a sale within a deadline. Ask a local property lawyer to confirm how your specific country handles this before you commit.