You must gather Heart Crystals from Underground areas, the Underworld, or the Dungeon, all of which are easier to explore before unlocking Hard Mode. These are Large Red heart-shaped crystals that give off a slight red glow/sparkle. You must "break" them with a pickaxe (edit thanks to RianBattle). Once you obtain a Heart Crystal, you put it in your top row and "use" it with cn_RT. Your character will hold it above their head and a green 20 will appear, which increases your max health by 20 (or one red heart), accompanied by a chime sound. You have maxed out your health from heart crystals when you have two full rows of red hearts, and when holding one a heart crystal no longer produces a green 20 (it takes 15 heart crystals in total).
NOTE: This is different from the hearts that creatures drop, which restore 20 lost health points.
For mana, you must collect stars that fall from the sky at night. You can increase their drop rate with a Star Fury sword, or by wearing a Star Veil. You must then craft these into mana crystals (fallen stars are yellow, and mana crystals are blue), which can be done anywhere without a crafting station needed. It takes 10 5 fallen stars (thanks Panthera onca) to make one mana crystal. You use these the same way as heart crystals. Each one increases your max mana by 20, and it takes 9 mana crystals to completely max out your mana total, since you start with one. Mana naturally refills itself over time.
NOTE: This is different from the blue stars that creatures drop, which restore 200 lost mana points.
To completely max out your health, you also need 20 Life Fruit as well to get completely max health. These are found ONLY in a Jungle after Hard Mode is unlocked. They come from cutting down the foliage in a Jungle Biome. They look like a small Gold Heart surrounded by a green heart outline. You use these the same way as heart crystals. Each of these increase your max health by 5 and will turn one of your red hearts into a gold one. You can completely max out your total health by 100 (which takes 20 Life Fruit total) for a grand total of 500 health. Your health is completely maxed out when you have two full rows of gold hearts.
This is another achievement easily completed via the duplicating method for the three items. Or you can get them from a friend who has saved them after getting max health/mana.
Your max health/mana is saved to your character, so you can use multiple worlds to farm the items, including other players' worlds.
These items are only found, they are never sold by NPCs or dropped from creatures.
Zealous Pottle2's idea about the sky bridge is useful for harvesting fallen stars, but I find it easier to flatten the normal landscape instead of adding another layer to the world.