MDF can be a problem to paint unless you know the trick. The edges will absorb the paint like a sponge. It's very difficult to get a nice coat on the edges. Below is the process I use to prevent the issue.
You will need a brush, cup will water and wood glue. Just fill the cup with the amount of water that is required for the project you are doing.
Mix glue into the water at about a 60/30 mix of water(60) and glue(40).
Stir the mixture well. Now sand the edges of the MDF with 220 grit sand paper. Get it as smooth as possible.
Paint all the edges with the water/glue mixture and let it dry completely. Two coats are better but one coat is usually enough.
The last picture shows the difference with one coat of white spray paint. The left half was coated with the water/glue mixture and the right was just bare MDF. To get the uncoated MDF edges painted can take several coats and usually make a mess. The coated MDF can often be painted in two or three coats. If you plan to paint MDF it is worth the time to treat the edges.