How to compute all space taken up by an app and its associated files
Later versions of Android do not count cache data when showing the app size. So you can f.e. see that Instagram takes 150 Mb of your storage while there are more than 2 Gb of Instagram cached data (true story!)

As for Whatsapp, the size of media sent and recieved via Whatsapp (images, videos etc) is not shown in Settings. But since these media are stored in Whatsapp folder, their size is counted when you look at folder properties in any file manager.