If something goes afoul, it goes badly wrong. When a prank falls afoul of the law, it crosses the line from just a joke to something much more serious.
Use the adjective afoul to describe things that conflict or clash. If a politician goes afoul of the rules about using taxpayer money for person items, she’s bound to pay for it in votes. Likewise, a party guest might accidentally go afoul of the etiquette about how much candy to grab from a fallen piñata. The original nineteenth century meaning of afoul was nautical, describing tangled ropes or lines on a ship.