In this paper we introduce the notion of horizontally affine, h-affine in short, function and give a complete description of such functions on step-2 Carnot algebras. We show that the vector space of h-affine functions on the free step-2 rank-$n$ Carnot algebra is isomorphic to the exterior algebra of $mathbb{R}^n$. Using that every Carnot algebra can be written as a quotient of a free Carnot algebra, we shall deduce from the free case a description of h-affine functions on arbitrary step-2 Carnot algebras, together with several characterizations of those step-2 Carnot algebras where h-affine functions are affine in the usual sense of vector spaces. Our interest for h-affine functions stems from their relationship with a class of sets called precisely monotone, recently introduced in the literature, as well as from their relationship with minimal hypersurfaces.