In this paper, the number and distributions of limit cycles bifurcating from a double homoclinic loop and a double heteroclinic loop of piecewise smooth systems with three zones are considered. By introducing a suitable Poincaré map near the double homoclinic loop, three criteria are derived to judge its inner and outer stability. Then through stability-changing method, bifurcation theorems of limit cycles near the double homoclinic and double heteroclinic loops for non-symmetric and symmetric piecewise near-Hamiltonian systems are established. A piecewise linear Z2-equivariant system is presented as an application and five limit cycles are obtained, three of which are alien limit cycles.