Silt and Sun
While in normal life, weapons can break for any number of reasons, in D&D they only break for two reasons, Plot and the player wanting to re-roll a 1. The first one is going to try to be avoided most of the time, so it’s mostly up to a player to make the decision.
When you are allowed to attempt a weapon breakage re-roll:
When you roll a natural 1 on an attack roll with a weapon or implement. These cannot be natural weapons or implements (A monk can’t choose to break his fist when doing an unarmed strike, but can choose to break his ki focus if he is using one.)
What happens when your re-roll:
You re-roll a single attack roll that was a 1. If you rolled more than a single natural one during the attack, you are only allowed to re-roll a single roll. All other rolls in the attack are as normal.
When does the weapon break:
If you have a weapon or implement crafted from normal materials, the weapon breaks at the end of the attack. Weapons immediately become improvised weapons, implements become broken and unusable.
If you have an iron, or otherwise stronger than normal weapon, and roll a 5 or lower on the re-roll, the weapon break as above. Otherwise the weapon is fine and no harm is done to it.
What happens when a weapon breaks:
As mentioned above, the weapon becomes an improvised weapon, while implements are broken. They can be fixed during a short rest, but will immediately break again on another natural 1, without the chance to re-roll the attack. This can be fixed by spending 1/5th of the purchase price on the weapon to get materials to repair it, and repairing the weapon during an extended rest. You can purchase such repair kits before the weapon breaks, if you want to carry some around with you.
The 1/5th purchase price is the total cost of the weapon. If you want to repair a level 1 magic item, you need to spend 360/5 = 72 gp.
The price is double if the weapon is made of iron, or other exotic materials.