Controlling the Phase and Stability of 2D MoS2 and WS2 for Catalysis and Optoelectronic Properties