Apps will ask you to or not go ahead
With a rooted phone, apps that are going to run with root rights, will prompt a dialogue first and only after an OK will the apps install or run. But I stand corrected when the apps themselves are insecure (unknown sources) and hence no dialogue will appear and there - you've a malware infected phone that may perhaps 'do anything' the hacker wanted it to do.