Here are some tips for miter cutting on a miter saw. 1) Make sure the saw is set up accurately. For cutting vertical miters, like you are doing, the saw head has to be exactly perpendicular to the table. Also the fence has to be exactly perpendicular to the table...don't laugh, some saws are not. 2) When cutting vertical miters, any variation in pressure by your hand holding the board against the fence can cause the miter not to be square. If you have more pressure on the top edge, the saw will cut more off the miter there. If you push in on the bottom, the saw will cut off more there. Believe me, if you take a miter that you already cut, check it with a square, then push against the top or bottom, which ever is long, and re-cut the miter, you will see the difference. 3) Miter cutting makes the blade want to dig in and wander off the line, so on long miter cuts it is best to make a rough cut about 1/16" off the line, then your final cut. That will keep the blade from wandering. 4) If your blade is dull and you try step 3, the blade will slide off the edge and you will never get a good miter. 5) If the board you are cutting is cupped, you will not get a straight miter. It will be concave or convex. This happens a lot when cutting baseboard that has been finished only on the front. Moisture gets into the back and causes that side to swell.
Those pointers should give you some things to watch for. I just built a walnut box with a lid to be used as an urn. The mitered sides were 4 1/2" tall. I paid attention to each of the steps I gave you to get perfect miters on that box.