Bunkers are one of the five defined areas of the course. Your ball lies in a bunker when any part of it touches the sand. So that the challenge of playing from the sand is preserved, there are a few things you are not permitted to do when your ball is in a bunker. These include testing the condition of the bunker, touching the sand right around your ball, and making a practice swing that touches the sand.
However, you can remove natural and artificial objects (loose impediments and movable obstructions) from the bunker since those are not considered part of the challenge of playing a ball from sand. In preparing to play from a bunker, you can set your clubs down in the bunker and rake the bunker to care for the course before playing, so long as you aren’t testing the bunker or improving the conditions for your next stroke.
You get free relief in a bunker when you have interference from an abnormal course condition (such as a drain or steps, temporary water, and ground under repair). If you want to take relief for an unplayable lie, you have the three standard one penalty stroke relief options of stroke and distance, back-on-the-line between the ball and the hole, or lateral relief within two club-lengths, except that you must drop your ball in the bunker for options two and three. Plus you have an additional fourth option, this time for two penalty strokes, that allows you to get out of the bunker by going back-on-the line between the ball and the hole as far back as you’d like.
Bunkers. USGA. (2023, January 1). https://www.usga.org/content/usga/home-page/rules-hub/topics/bunkers.html