Things can still "spread away from each other" and be attracted to each other. In this case the "spreading" just needs to overcome the force of attraction. Although the force of gravity is infinite, it is also considered a very weak force.
If everything in the cosmos is expanding away from itself, how do you know that they're all attracted to one another? 
By observation and experimentation.
What experiments did you conduct on the cosmos to prove that they are all attracted towards each other?
If those objects appear to be spreading away from each other, it does not mean that they do not exhibit any attraction at all.
It doesn't lead to the conclusion that they
do exhibit attraction either. In fact it leads to the direct opposite conclusion.
I'm not sure why you insist that something is happening when it's not.
Attraction does not mean that things will 100% of the time get closer to each other. There are so many variables to count for.
An example for you Tom. Get 2 magnets. Put them together so they 'stick' together.
Now, very slowly, start pulling them apart.
As soon as you slowly start pulling them apart, do they lose all attraction 100%? Or do they still attract each other while still moving away?
EDIT: As the ones who have done this example before know the outcome, we call all say Tom has his thought process going the wrong way. Maybe they let some noob have a go at using his account, instead of one of the others.
If things are moving away from each other it cannot be concluded that they are attracted to each other.
If magnets are observed to be moving away from each other at an accelerated rate, does it lead to the conclusion that they are attracted to each other? No.
If the stars are all moving away from each other at an accelerated rate, does it lead to the conclusion that they are all attracting each other? No it doesn't.
If Mary puts a restraining order against John and moves to another state, does it lead to the conclusion that Mary is attracted to John? Nope. (But I'm sure you'll tell me that Mary is attracted to John, and that it was her invisible step mother who filed the restraining order in her name and forced her to move away)
The fact is that the conclusion of universal gravitation between all bodies in the cosmos is an unfounded speculation with no relation to the real world. There is absolutely no evidence behind that assertion. There is no observational, experimental, or meaningful evidence suggesting that all bodies in the heavens are attracted towards each other.