The theory of general relativity was formulated around 1915 which could be summed up in words of John Wheeler, "Space-time tells matter how to move; matter tells space-time how to curve".
At that time the unanimous consensus was arguably that the universe was static which essentially meant that there was no relative motion between different objects in the sky. For example, according to static universe model, the distance between Milky Way Galaxy and Andromeda Galaxy does not change. This led Einstein to use cosmological constant so that the matter does not collapse or contracts onto itself as a result of gravitational attraction.
I don't think that Einstein was thinking that the collapse or contraction of matter would also result into the contraction of space onto itself as well. Yes, if the matter had collapsed onto itself, it would've curved the space around it. (I'm avoiding the term black holes on purpose since I'm looking at it in historical time frame.) In other words, I don't think it was really known at that time that the space could expand/grow or shrink.
In 1912, Vesto Slipher discovered that light from remote galaxies was redshifted, which was later interpreted as galaxies receding from the Earth. In 1922, Alexander Friedmann used Einstein field equations to provide theoretical evidence that the universe is expanding.
Swedish astronomer Knut Lundmark was the first person to find observational evidence for expansion in 1924....
In 1927, Georges Lemaître independently reached a similar conclusion to Friedmann on a theoretical basis, and also presented observational evidence for a linear relationship between distance to galaxies and their recessional velocity. Edwin Hubble observationally confirmed Lundmark's and Lemaître's findings in 1929. Assuming the cosmological principle, these findings would imply that all galaxies are moving away from each other.
I think that Vesto Slipher could have concluded that it was the relative motion of the galaxies which was producing redshift. For example, Galaxy A is moving away from Milky Way Galaxy at 500 km/s and Galaxy B moving away at 800 km/s. My point is that concluding that the space itself is growing between different objects, in my humble opinion, was quite a radical idea in its own right. It could also have begged another equally valid question that how and why the space was growing.
Also, though the Wikipedia article says that Friedmann used the relativity's equations to provide the evidence that the universe was expanding. In my opinion, Friedmann could have equally chosen to prove that the universe was contracting unless he was motivated by experimental evidence, such as the observation of Slipher, that the expansion was more probably than contraction. The question is that when it was being said that the universe was expanding, what that term 'expansion' was referring to? Was it referring to relative motions of the objects moving away from each other, or was it referring to the expansion of space itself? If it was the space itself, where did they get the notion that the space could grow on its own? I don't think the theory of general relativity said anything about the expansion of space. Could you please help me with it?
I know sometimes people tend to retrospectively read more into a theory more than it was really modelled for. For example, saying that Einstein or the theory of general relativity predicted black holes and gravitation waves is not really correct. Yes, the predictions/hints/pointers were really embedded there or hidden in the framework of the theory but Einstein didn't really predict it or hinted at it. When Einstein formulated the theory, his concern wasn't really to solve or predict the blackholes or gravitational waves. I'd say it's true of any theory. I'm saying this in the hope that I'm not told that the theory predicted the expansion of space even when it initially didn't.
Also, if you check the link below, De Sitter's model of expanding? universe was something quite weird, if I may say so. IMHO, I don't think if calling it expanding universe model is the right thing to do. De Sitter wasn't really talking about the expansion of space, his model was along different lines of thought.
More information could be found here: https://history.aip.org/exhibits/cosmology/ideas/expanding.htm
Thanks for the help and time!
This edit has been made after the comment of @Conifold.
I think that Einstein's original equations of the theory of relativity predicted contracting or expanding universe. I'd say that the mathematics predicted either contracting or expanding universe. I'd say that this mathematical prediction of contraction or expansion was a result of (pseudo-)Riemannian geometry used to formulate the theory of general relativity as mentioned by @Conifold.
This is how I see the mathematical formulation of general relativity. The formulation of the general relativity assumed the material objects embedded into immaterial space-time. Think of space-time as a grid. The immaterial space-time can contract and expand independent of the material objects embedded in it. The material objects could be attracted to each as a result of gravity independent of the space-time, (or, repel as a result of charge).
In my opinion, this is an important point. Einstein was one of the great physicists of 20th century who really valued physical and intuitive interpretation of the theories. I personally admire him for this. That's one of the reasons Einstein agreed to Friedmann's solution but considered that it didn't have physical validity. Likewise, later Einstein considered Lemaitre's solution mathematically good but not valid in terms of physics. That's also the reasons Einstein had doubts about blackholes and gravitational waves. That's also one of the reasons Einstein had problems with the interpretation of quantum mechanics. In other words, Einstein clearly drew a line between the mathematics of theories and their 'physical' interpretations.
I'd agree that the formulation of general relativity in terms of (pseudo-)Riemannian geometry allows for expanding or contracting universe.
I think that my original question could be phrased better as follows.
Einstein was concerned about all the matter collapsing onto itself as a result of gravitational attraction since gravity doesn't go to zero. He introduced the cosmological constant to fix the problem though he didn't really like doing it. Einstein chose such a value for cosmological constant that it fixed the contracting universe problem for him but if he had used other value (for example negative value instead of positive ) it would result into expansion. Could you please point me to any source which shows that Einstein really believed that the space itself would also contract or collapse along with the matter as a result of gravitational attraction? If Einstein did believe in the contraction of space, wasn't he bothered by it and thought about its cause? Was the contraction and expansion simply the assumed properties of space-time 'grid' by Einstein?
Also, in my opinion, Einstein gave importance to the idea of contracting universe not simply because the mathematics allowed it, he also saw 'physical' cause for this contraction which was gravity. He didn't see any physical cause for the expansion therefore I think he didn't give it any consideration though the mathematics allowed the expansion.
Later around 1930 Einstein agreed to the expanding universe model but was he comfortable with the expansion of space itself as he was mostly concerned, as I stated above, about the physical reality? Again, was the contraction and expansion simply the assumed properties of space-time 'grid' by Einstein?
Just a side note. What Friedmann did was more of a mathematical exercise which turned out to make sense later. Friedmann presented both contracting and expanding models.
References used for the Edit section:
1: A century ago, Alexander Friedmann envisioned the universe’s expansion by Tom Siegfried, https://www.sciencenews.org/article/alexander-friedmann-universes-expansion-1922-cosmology
2: Einstein’s conversion from his static to an expanding universe by Harry Nussbaumer, https://arxiv.org/ftp/arxiv/papers/1311/1311.2763.pdf
3: How Friedmann Shod Einstein by Vladimir Soloviev, https://arxiv.org/pdf/2204.10650.pdf