We study the dynamics of flow-networks in porous media using a pore-network model. First, we consider a class of erosion dynamics assuming a constitutive law depending on flow rate, local velocities, or shear stress at the walls. We show that depending on the erosion law, the flow may become uniform and homogenized or become unstable and develop channels. By defining an order parameter capturing these different behaviors we show that a phase transition occurs depending on the erosion dynamics. Using a simple model, we identify quantitative criteria to distinguish these regimes and correctly predict the fate of the network, and discuss the experimental relevance of our result.