This is a subjective topic and varies from person to person. I think that this is a skill that must be developed over time and some people are better at it than others... but largely I can tell you the following:
1. Remove the unfun parts of the game. A lot of times what makes a game not fun is if there are boring/frustrating/annoying aspects to the game that take away from the enjoyment. For example having to switch control schemes, overly complicated control schemes, buggy game mechanics, sloppy collision detection, annoying sound effects... Imagine if your platform game has a platform that requires you to jump "perfectly" to land on it... and it takes lots of attempts which makes the game very difficult for no reason... this would make the game less fun.
2. Get other people to play test the game. Often people are good at telling you what they don't like. You need to find people who are willing to be honest with you and let you know what they think. You don't want the play testers to feel like they can't let you know what they honestly think even if it is very negative.
3. Remove repetition and add detail. If your game has the same elements that repeat over and over then this will get boring. You also want to add variety to your levels. In a lot of games you want your levels to tell a story... you want each level to advance the plot/progression of the player and for the level itself to be unified. For example if you have a game set in a jungle then you would want the elements of the level to convey this setting. If you are fighting giant spiders in the jungle then you would want the spiders to emerge from a logical place in the level and you would want a way to avoid/hide from the spiders to be built into the level. If a giant invincible spider was to spawn from no where and kill you in one hit with you unable to avoid the spider, then that would be frustrating and not fun.
4. You need to playtest the game and balance the game elements. There are many parameters you need to tweak when developing a game. You need to adjust speeds, gravity, hit points, etc so that everything is well balanced.
Essentially your game will likely not start off fun. Fun emerges when you remove the boring/annoying/repetitive parts and add mechanics that balance well with each other.
I hope this didn't ramble too much .