In this paper, by introducing the notion of "distributive constant" of a family of hypersurfaces with respect to a projective variety, we prove a second main theorem in Nevanlinna theory for meromorphic mappings with arbitrary families of hypersurfaces in projective varieties. Our second main theorem generalizes and improves previous results for meromorphic mappings with hypersurfaces, in particular for algebraically degenerate mappings and for the families of hypersurfaces in subgeneral position. The analogous results for the holomorphic curves with finite growth index from a complex disc into a project variety, and for meromorphic mappings on a complete Kähler manifold are also given. For the last aim, we will prove a Schmidt's subspace theorem for an arbitrary families of homogeneous polynomials, which is the counterpart in Number theory of our second main theorem. Our these results are generalizations and improvements of all previous results.