It’s almost always safer to download an app from the official stores, namely Apple Store for iPhones and Google Play Store for Android, rather than from a website. Saying this though, even the most reputable stores can suffer from tampered apps and hacking.
Apple and Google both have strict procedures where they check the security and safety of their apps before allowing them onto their stores.
They also remove apps from their stores if they suspect they contain malware, but sometimes they can go unnoticed. A recent study by Boston University uncovered that Google takes on average 77 days from detection to remove apps that potentially contain malware.
For the most part, downloading an app from the official app stores is legitimate and safe.