Sometimes its unavoidable in really tight anchorages, but you need to be so much more careful if you anchor in front of another boat. There is a good reason for this and why you should always anchor behind another boat.
When you anchor you have a swing circle and that circle is defined by the amount of anchor chain you have out.
If you arrive into an anchorage with very little wind it can be very hard to know if the boats are at the edge of their swing radius, but if there is a reasonable amount of wind they will be.
Therefore if you anchor behind them, relative to the wind, you will be setting your anchor at the edge of their swing circle and unless you have much more chain out than them you should never overlap. It’s a pretty safe situation.
But if you anchor beside or in front of them you can get an overlap situation very easily, even though it might look safe, when the wind changes angle you may find they are inside your swing circle.