I thought that matter could neither be created nor destroyed.
In this universe that is correct, sort of. But it has no bearing on what may or may not happen "outside" our universe.
Besides, if the net energy of the universe is zero, then it's still technically a gain of nothing, just like virtual particles can be created, but generally they cancel each other out so there is no net gain.