Matthew 25 is a description of two kinds of people - the wicked and the just. The just, those whom God has made just, are His sheep placed on the right hand and told they've done all these good works. Alright, this is a description, and you'll notice they weren't even aware they had done these things. Why? Well, they weren't doing them for gain, they were doing good works because God had worked on their hearts. He had taken out the stoney heart and replaced it with a heart of flesh, and now they delight in the law of God and in denying self and doing things for others. The wicked, gathered to the left hand, are told they haven't done these things. This is a description of the wicked, who are consistently consumed with self and are generally unconcerned about the general welfare of those around them except when it profits them. You'll notice that these people aren't even repentant of their actions.
The people didn't perform these actions to get into that group, they did these things because they were already in that group. The righteous do good works because God has changed their heart. The wicked do not because they are still in their natural state.