There is a well known process for taking mass away from nebulae (star formation) but there are many processes for putting mass back into nebulae as well. Stellar winds (which are very strong for extremely young, old, or massive stars) and supernovae being the most prominent examples. Star formation is not a very efficient process, a lot of the mass of a collapsing proto-stellar nebula does not end up in a star, it goes back into interstellar space where later it may become part of another nebula and participate in the formation of another start. Also, the amount of gas and dust in a galaxy is very significant, around 10-15% of the mass of all stars within our own galaxy, for example. Between that and the processes that distribute mass back to the interstellar medium star formation can continue for a very, very long time.