FOR SILVER:

Why my beautiful silver jewellery became tarnished? Does this means there is something wrong with the purity of the metal?
Silver as a natural material reacts with its environment, especially the chemicals in the air and, over time, silver does become tarnished. 
Not at all, in fact it just proves that your beautiful accessory is good quality silver. 

How can I prevent this?

Wear:
You can avoid tarnish by wearing your jewelry often. The oils in your skin will "clean” the silver and keep it looking shiny.

Avoid exposure:
Direct sunlight causes silver to tarnish, so be sure to take off your silver jewelry before you go swimming and sunbathing. Also don’t wear your jewelry when you shower, in the swimming pool or in a hot tub.
Cosmetics, hair products and spray, lotions and perfumes are also bad for your silver and will accelerate tarnishing. Jewelry should be the finishing touch to your look, so next time you’re ready to go out remember to put on your beautiful accessories last. 
For the same reasons avoid wearing them when you’re doing an intense sport activity, a violent movement may rip your delicate name necklace in two pieces. Also be careful when you change clothes, as jewelry has the habit to get tangled with clothes especially with woolen ones.
Contact with household chemicals, chlorinated water, perspiration, rubber, or any substances which contain sulfur (e.g., mayonnaise, eggs, mustard, onions, latex, wool), will cause corrosion and tarnish — so it’s a good idea to remove silver jewelry when doing household chores. 

Storage:
As exposure to air tarnishes it, storing silver in airtight plastic bags with anti-tarnish strips is a great preventative measure. Just make sure you don’t store multiple jewelry pieces in the same bag: silver is a soft metal, so the individual pieces can scratch each other. Link or chain bracelets should be kept unclasped or unhooked to prevent scratching as well. If you can’t use plastic bags, try to make sure that the storage area has low humidity. You can also place a piece of chalk, a packet of activated charcoal, or a container of silica gel in the storage area to minimize tarnish.

How can I clean them?
You can use a polishing cloth to remove tarnish and if this is not enough you can use the following easy, economical and environmentally friendly methods:

Soap and water: 
Warm water and a mild, ammonia- and phosphate-free dishwashing soap should be your first line of defense if the polishing cloth fails to remove tarnish. Soap and water should also be used to clean your pieces before using any of the methods listed below.

Baking soda and water:
Make a paste of baking soda and water and use a clean cloth to apply a pea-sized amount to the silver and polish. For etched, stamped or detailed items, thin the paste with more water and use a clean, soft-bristled toothbrush to get the cracks and crevices. Run the silver piece or pieces under running warm water, and dry with a clean cloth.

White vinegar and baking soda:
Use this gentle cleaner to remove heavy tarnish that’s preventing you from polishing your silver. Soak the tarnished piece in a solution of 1/2 cup white vinegar and 2 tbsp. baking soda (be prepared for the fizzing!) for two to three hours, then rinse and dry.

Baking soda, salt, aluminum foil, and boiling water: 
You can take advantage of a simple chemical reaction to clean your silver: all you’ll need is some baking soda, salt, and aluminum foil. Line a glass roasting pan or the kitchen sink with aluminum foil, dull side facing down. Place the silver pieces on top of the aluminum foil. Then pour boiling water over the pieces until they are covered and add 2 tbsp. each of baking soda and salt. Stir the solution to allow the baking soda to dissolve — you don’t want any granules scratching the metal.
The reaction causes the tarnish to transfer to the foil, and in about 5-10 minutes you’ll see the tarnish "magically” disappear from the jewelry. (Be prepared for the smell of rotten eggs, though, as the sulfide tarnish comes off the silver.) Using salad tongs or nitrile gloves (not rubber gloves, which contain sulfur), remove the silver jewelry from the hot water or drain into a colander. Rinse the jewelry with warm water, then dry and buff with a soft cloth. 

Sometimes these methods are not enough, you can try some of the silver care products that’s on the market or sometimes jewellery needs professional help from a professional silver cleaner. Very old, fragile, or valuable pieces should also be cleaned by a professional.

It should be noted, however, that silver cleaners are not for all types of silver jewelry. You should not, for instance, ever immerse jewelry adorned with pearls or opaque gemstones (e.g. turquoise, opal, carnelian, onyx), as this could seriously damage these softer stones. (Give these pieces a very brief rinse if they become too dirty.)
Even for jewelry with clear gemstones (e.g. blue topaz, amethyst, garnet), take special care when using a silver cleaner: the chemicals could lodge under the gemstone settings or loosen any glue. And remember, do not use silver cleaners on your oxidized jewelry — stick to the polishing cloth instead.
After using any cleaner, be sure to thoroughly rinse your silver with warm running water or a clean, damp cloth. This is especially important for detailed or etched items, since polish can stick in small crevices and harden. After, dry the pieces with a microfiber cloth to prevent white water spot stains from forming.


FOR GOLD JEWELLERY

Some of the above instructions for silver applies to gold too. You must take off your gold jewellery before going for swimming and sun bathing. Remove all gold jewelry before showering or cleaning.

Soap can cause a film to form on karat gold jewelry, making it appear dull. By preventing the formation of this film, you immediately reduce the occasions your pieces will need to be cleaned.

Be careful of chlorine it can permanently damage or discolor your gold jewelry. Do not wear gold jewelry while using chlorine bleach or while in a pool or hot tub.
You can remove tarnish with a jewelry cleaner, or by using soap and water.
Carefully brush with a soft toothbrush. After the brushing, simply rinse with warm water and allow to dry.

If there is a heavy tarnish on your jewelry, consult your jeweler for the best cleaning procedure. You should also talk to your jeweler before attempting to clean any karat gold jewelry set with colored gemstones because some stones require special cleaning procedures.