Using a sander or even a sanding block on the narrow edge of a workpiece can be tough. There’s not a lot of real estate there to balance the sander properly, making it easy to inadvertently rock the sander side to side and round over crisp edges.
The trick here is to make the edge temporarily wider by clamping a straight piece of stock beside the edge to use as a sanding guide. This effectively doubles or triples the edge width, creating a more stable platform for supporting the sander.
Sometimes, especially for edge sanding, a powered sander isn’t the best choice. For smaller workpieces, the easier way to edge sand is using a simple trick I learned years ago. Head over to your table saw and lock down the rip fence. Now, slip a full sheet of sandpaper underneath the fence and hold it down from one side. Place the workpiece against the other side of the fence and rub it back and forth over the paper. You’ll be surprised at how quickly you’ll get a square edge with perfectly crisp corners.
For profiled edges, unless you have a powered contour sander, hand-sanding is the best bet. You can wrap small pieces of sandpaper around a dowel or other round object. Or use a set of contour sanding grips, like the ones available from Rockler.