I can answer for the US here in stating that manufacturers are required to have available OEM parts for five years after manufacture of a vehicle. There is no requirement for the OEM manufacturer to ensure aftermarket parts are available. Something to note is, manufacturers will use the same parts across several lines of vehicles for several years. When doing so, this means they'll have the parts for five years after the last vehicle uses it.
The only way an aftermarket part becomes available is if there is a call for them (ie: people want to buy the replacement parts). If it is lucrative enough for them to make/produce/procure the replacement parts, they'll do it. If they aren't going to make money at it, then they won't. In the case of when a part is no longer available through the OEM or aftermarket, the next best thing is a parts car, usually pulling parts from one at a junkyard.
I don't know about outside of the US, but I would assume it is something similar.