Treating differential operator as algebraic entity

I was reading e:the story of a number by Eli Maor, where he treats differential operator as just like any algebraic entity.

For example if we have a differential equation like y’’ + 5y’ - 6y = 0. This can be treaed as (D^2 + 5D – 6)y = 0. So, either y = 0 (trivial solution) or (D^2 + 5D – 6) = 0. Factoring out above equation we get (D-1)(D+6)= 0 with solutions as D = 1 and D = -6. Since D does not have any meaning on its own, multiplying by y on both the sides we get Dy = y and Dy = -6y for which the solutions are Ae^x and Be^-6x. Combining these 2 solutions we get Ae^x + Be^-6x.

Now my doubt is this approach break when we have an equation like D^2y = 0. Which means y = 0 (again trivial) or D^2 = 0 which means D = 0. Now Dy = y*0 = 0.

That means y = C ( a constant). The actual answer should be Cx. I know that it is stupidity to treat D^2 = 0 as D = 0, it led me to doubt the entire process of treating differential equation as algebraic equation. Can someone throw light on this?