You don't have to switch to Apple, just make different choices on Android makes. Some are better than others when it comes to getting updates out and Google has NO ability to force manufacturers to update. Apple can update their phones for 3 years because they control every aspect of the devices and with the exception of the screen size all their iOS devices are largely the same so over the course of 3 years they have maybe a half dozen total hardware configurations to support.
Android has a MUCH larger hardware base (Samsung ALONE releases 6 devices in a single year) and as a result Google has to leave it to the chipset and device manufacturers to provide continuing support for the devices. If you were to go with a Nexus device, you'd get at least 2 years of major OS updates and probably another year (or possibly even more) of monthly security updates. Only Google has committed to those time frames, no other manufacturer has committed or delivered on a commitment like that. The reason Google can do it with the Nexus devices is because they are essentially Google's development platform FOR Android, essentially the iPhones of the Android world.