Can anyone explain how an user can access my hosting account and then upload files there. Is it because I dont change my ftp details frequenltly. Because recently I found in all my domains a sample php file with a name of hacker was uploaded, which I deleted afterwards and change all my related passwords
Sounds like your account has Been compromised. It could be through someone getting hold of your login credentials, but more likely it is down to an insecure script your using on your site. Are you running any apps like Wordpress, phpbb etc? Make sure you are running the latest versions. It sounds like you are renting your hosting space, I would talk to your provider as it may be something they can help with.