Stochastic Matching Networks: Theory and Applications to Matching Markets