Mass is a type of energy and can be converted into other types (for example, during nuclear fusion when hydrogen nuclei can convert into helium nuclei and release energy). Black holes do not violate the law of conservation of energy. When gas or other material falls past the point of no return (called the event horizon) and into a black hole, the exact amount of energy (including mass) contained in the material as it falls in is added to the black hole. So the total amount of energy in the system doesn’t change.
Astronomy magazine subscribers can read the full answer for free. Just make sure you're registered with the website.