Sediment traps are intentionally installed to help prevent sediment in the gas piping from getting into the gas valve or burner area of an appliance and fouling things up.
Furnace gas line sediment trap.
The most frequent improperly configured sediment trap is where the gas supply connects to a tee fitting installed with the tee tap facing down the gas supply is connected to one end of the horizontal tee the appliance is connected to the other end of the horizontal tee and a short nipple is installed into the down facing tee tap the nipple is then capped.
This could be things such as metal shavings from pipe cutting and threading during gas line installation at the home or dirt that may have gotten in to the line from utility crews installing gas mains underground.
Sediment traps installed at gas appliances are used to help catch any sediment or debris that may be present in the gas line and prevent it from entering the appliance and possibly damaging it.
Most water heaters do not have a sediment trap in them.