It's probably simpler than that: it's simply not energy-efficient to keep producing an enzyme throughout its life for a sugar that's rare-to-non-existent in an organism's diet for most of that life. Because mammals don't have any means of obtaining milk once they separate from their mother, lactose intolerance for their lifetime after weaning is almost universal among mammals. Over millions of years, the slight energy efficiency win of turning off that enzyme's production post-weaning probably won out.
Humans are odd in that we harvest milk for consumption at all beyond our own mother's, which is probably why we're the only species with a notable population with the genetic mutation that allows some of us to digest it – there's no competitive advantage to that mutation in most other mammals, because where would they even obtain milk?