Historically these were single family homes, built for an urban context in which land is valuable, and lots are deep and narrow. Larger (in this context taller), more ornate ones like the ones shown in the post were built for the upper classes, but in most cases have since been divided into 3-4 walkup apartments, one on each floor. There were also rowhouses built for working-class families, especially in Brooklyn. These were smaller (usually no more than 2 stories) and less ornate. Today they might be divided into 2 apartments, but this is less common than in larger homes as these already have less space and the additional income to be made from apartment conversion is less significant.
Edit: additionally, larger homes for the upper-class often contained servants quarters in basements and/or attics, so they were, in a sense, multi-family. These spaces were also very simple to convert into apartments.