Einstein used the cosmological constant to prevent expansion which he regarded as his greatest blunder. On the other hand, we are saying that the cosmological constant can cause the space expansion to accelerate. How can the same thing be responsible for causing two opposite effects i.e., preventing expansion on one hand and cause the expansion to accelerate on the other? Thanks!
The cosmological constant does not cause two opposite effects. It causes our universe to expand accelerated. In general the cc can be considered as repelling gravity.
Einstein believed that the universe was static. This requires that attractive gravity due to matter has to be cancelled by repelling gravity. Therefore he introduced the cosmological constant, in order to prevent that the universe was not static.
Consider this analogy. You can (1) shoot a projectile away from the earth at greater than escape velocity, (2) have an object fall to earth from infinitely far away, or (3) throw a ball up and have it come back down. These are the three types of (purely radial) motion in the earth's gravitational field, and they do not include any case of static equilibrium. You can't have a static equilibrium, because gravity is purely attractive.
Without the cosmological constant, the equations of general relativity have three types of solutions: expanding at all times, contracting at all times, and expanding but then recontracting. This is analogous to the cases 1, 2, and 3 described above.
Adding a repulsive cosmological constant is like adding rocket propulsion to your projectile. It can cause the rocket to accelerate away faster and faster. Or another possibility is that, if it is carefully adjusted, it can cause the object to hover in place.
I think you have both a conceptual and a historical misconception that need to be cleared up.
First of all, you need to distinguish between the universe's rate of expansion, which is roughly like a radial velocity, and its rate of expansion acceleration. The cosmological constant and "ordinary" attractive gravity together determine the acceleration of the expansion. Roughly speaking, a positive cosmological constant causes all matter to accelerate away from each other and the attractive effect of ordinary gravity causes matter to accelerate toward each other. If ordinary gravitational attraction (as determined by the average matter density of the universe) is "stronger" than the CC then matter will accelerate inward; and if the CC is "stronger" then it will accelerate outward. But in either case, the actual expansion itself can be positive (outward expansion) or negative (inward contraction), regardless of the value of the CC. By analogy, Newton's law of gravity tells you that on the surface of the Earth, thrown balls will accelerate downward, but it can't tell you whether at any given instant a specific ball is moving upward or downward; that just depends on the initial conditions, which are not within the purview of the fundamental theory.
Einstein incorrectly believed that the universe was static, so that both the expansion and is acceleration had to always be zero. He added in a CC to exactly balance and cancel the attractive influence that the universe's matter exerts on itself and ensure zero acceleration. (The first sentence of your question is incorrect; Einstein used the cosmological constant to prevent contraction, not expansion.) Even if his value for the CC had been correct, it would still have been compatible with either uniform expansion or contraction, so he had to separately postulate that the expansion was zero.
A few years later, we discovered that the universe was expanding. This observation by itself does not imply anything about the value of the CC: the fact that a ball is instantaneously moving upwards doesn't tell us anything about the strength (or even the sign) of the force of gravity on Earth. Einstein only proposed eliminating his CC on the grounds of simplicity, not because he had positive evidence that its value was zero.
For the next 76 years, cosmologists assumed that the universe was expanding but that the expansion was slowing down - just like a ball on its upward trajectory - as matter pulls on itself and slows the expansion. To greatly simplify, they assumed that eventually the expansion would reverse itself and the universe would recollapse in a Big Crunch.
But we now know that the universe's expansion is accelerating in the positive ("outward") direction. This means that Einstein's mistake was not in including a positive CC, but actually in underestimating its strength. On cosmological scales, the repulsive effect of the CC actually wins over the attractive effect of ordinary gravity and the universe expands faster and faster as the ordinary matter thins out to more and more dilute densities.