There is an attractive force of gravitation that acts between all bodies with mass. Under normal circumstances there are several repulsive forces which include those between sub-atomic particles that exceed the attractive force of gravity.
In the case of stars, the gravitational force of attraction between the atoms of gas that makes up the stars is initially less than the repulsion due to energy released by fusion. When stars have used up all their fuel and no more energy is being released due to fusion different phenomena take place depending on the initial mass of the star. The lighter ones explode to form what is called a supernova, most of the mass is expelled and a small amount of mass called a white dwarf is left behind.
If the mass of the star is more than 3-4 times that of the Sun, after fusion stops, there is enough mass to start a collapse of the star inwards and there is no opposing force; even that of the force of repulsion between sub-atomic particles does not exceed the attractive force of gravity. As the star collapses, its gravitational force increases and so does the rate of collapse. The result of this gravitational collapse finally creates a body with an infinitely powerful gravitational field from which nothing can escape. This is a Black Hole.