Professional painters tend to paint the ceiling first, then the walls, then window trim, according to painting retailer Sherwin-Williams. This usually has to do with convenience and timing. A professional painter, though, has a steady hand and experience painting the trim without dripping paint onto the walls.
One thing you may want to consider is the paint color. It's easier to paint over mistakes that you make with a lighter color, so it's smart to paint with the lighter color first. If the trim will be darker than the walls, you can paint the walls first. Alternatively, paint the trim first if that's lighter than the walls.
Painter's tape protects areas from getting painted. It's usually easier to apply the tape to the wall, since this is a flat surface and the trim is likely to be curved. In this case, it's smart to paint the walls first, allow them to dry, then apply the tape around the window before you paint the trim.
Using painter's tape can be time consuming; if you just want to get the job done, you don't have to use it. In this case, though, it's usually easier to paint the smooth wall around the trim without making mistakes than it is to paint the trim, so you'll want to start by painting the trim, then carefully outline the trim with your wall color before painting the wall with a roller.