Equivalence and stable isomorphism of groupoids, and diagonal-preserving stable isomorphisms of graph C*-algebras and Leavitt path algebras