If you're in the market for a new smartphone or tablet, one of your most important criteria should be a long support life of security updates. When your device stops getting security updates, the longer you continue to use it, the larger the target painted on your back becomes, due to the security vulnerabilities that start accumulating.
Android versus iOS (iPhone or iPad) is often a personal, quasi-religious choice, but, functionality aside, it's fair to say that iOS is more secure but generally more expensive than Android.
This is a great article to help you understand security updates by brand for Android:
8 Best Android Phones (Unlocked, Cheap): Our 2021 Picks | WIRED
Look especially at the number of years of security updates provided, since when the security updates end, your phone or tablet becomes only a good paperweight. Brands that license Android from Google usually have a shorter support life than Google has for its own devices (Nexus brand).
N.B. The number of years of security updates is from when the device is released to the market, not from when you buy it! So you have to find the release date for a device you're looking at. You could do a web search for the brand and model of the device combined with "release date".
Apple does a better job of providing security updates, so an iOS device will almost always get 4 or 5 years of security updates. And this year, some 5-year-old iOS devices are getting an extra year of support, for a total of 6 years, but that's unusual.