The bowline has two variants, one being the cowboy version, which has the working bitter end on the outside of the loop, the "normal" bowline will have it on the inside of the loop.
To tie a bowline, make a loop in the working bitter end up about 2x the desired circumference of the loop you want to make. Your line is now segmented into the bitter end, and the standing line section.
Look at the loop. You want to put the bitter end through the same side of the hole where the bitter end overlaps the line/rope on the other side of the loop (standing section). If you use your right hand to twist the loop, and do so clockwise, you will insert the bitter end from the top. If you turn it counter-clockwise, then you will insert it from the bottom.
In this orientation, if you go around behind the right side of the standing part, you will form a normal bowline. If you go around behind on the left, this will form a "cowboy" bowline. Either works, but the cowboy one allows the bitter end to hang loose, which increases the odds of it getting caught up in other lines.
Finish by inserting the bitter end into the same hole from the other direction (obviously).
If you find the knot comes undone, you are putting it through the wrong side of the hole at the start. Just insert it in the other side and this particular problem solves itself. If you are on a boat, other problems may now be selected for attack. :P