Everyone is welcomed to pray and attend a Catholic Mass. However, toward the end of the Mass, Communion will be distributed. People will leave their seats and walk toward a priest, deacon or other minister and receive communion. Only Catholics and Catholics in good standing not conscious of any mortal sin may approach to receive communion. Catholics believe that Jesus is present in the Communion that we receive and when we receive it worthily, we are contributing to our salvation. On the other hand, if we receive communion unworthily, then it brings about condemnation instead of salvation. For that reason, those who are conscious of mortal sin (serious offenses against God) should not receive communion. In order to be absolved of our sins, we confess them to a priest during confession. The priest stands in the role of Christ and after hearing our offenses forgives us our sins in the name of Christ under the condition that we are truly sorry for our offenses and gives us a penance to do or perform.
This is an over-simplified explanation of things and it may overlook certain points but it gets the basic elements across. The bottom line is that if you are not a Catholic, you can not go to confession and should not approach to receive communion during that portion of the mass.
If / When you become a Catholic, confession is REQUIRED once a year and RECOMMENDED once a month. You can go as often as you feel the need. The Pope goes to confession three times a week. Mother Theresa went to confession once a day. The important thing for a Catholic is not to receive communion when in a state of mortal sin and if you are conscious of a mortal sin, then you should go to confession as quickly as possible.
Again, I am speaking in over-simplified terms. If you have specific questions, feel free to ask them and I or others will try to answer them in more detail.