How to prevent an app from being uninstalled? Is there any permission or method to prevent an app from being uninstalled even after factory reset like system app that does not get uninstalled?
You will have to root your device and move the app using any application to the system folder. This will enable your app to be on device even after you have formatted your device. 

Here is the link of application which provides this administrative feature:

/system/app mover ★ ROOT ★

This app moves apps from and to the /system/app folder, making them a system app or a user app. System apps can get more priviledges, so some apps get more functionality when installed as a system app.
On the other hand, system apps can not be uninstalled. So this app can also be used to convert system apps to normal user apps by moving them from the /system/app directory to /data/app directory.

WARNING: Uninstalling important system apps might result in a unusable device! Use this function at your own risk and only if you know what you're doing! Make a NANDroid backup first! I won't give any kind of support if something goes wrong - don't install this app if you're not okay with that.