Why is 狗屎运 a commendatory term? When we use 狗屎 (dog's excrement) to describe a thing, it is definitely negative. Sometimes it can also appear as a bad word.
Also, 踩到狗屎 is obviously a bad thing.
But, 狗屎运 (good fortune) is used positively.
What causes this difference?
狗屎运 is an accidental luck and some good things you don't expect suddenly come to you. It's fine to use it in informal situations, but it's still a vulgar term.  Sometimes, it can be taken in a funny way, but you should be cautious when you use it in a formal situation.