I tried to make an electromagnet at home but when I connect the two copper wires to a 1.5V battery it keeps short circuiting and heating up. Also it doesn't attract other nails.
You can determine the power of a magnet (very roughly) using the following equation:
B = μ₀ * n * I
Where:
B is the magnetic field strength in teslas (T) or gauss (G).
μ₀ is the permeability of free space, approximately equal to 4π × 10^-7 T·m/A.
n is the number of turns per unit length of the coil (turns per meter).
I is the current flowing through the coil in amperes (A).
So the number of turns matters, and also the current matters.
But there's a third thing, and I think that's the problem you're having: This piece of wire is conductive, and the nail is conductive, and there doesn't seem to be any insulation on the wire. Because of that, the current flows through the wire on one side, into the nail and across it, then out the wire on the other side. The current needs to flow in loops without being able to take any other path, The coil of wire and the current flowing around in circles is what's required.
What you want is a long piece of wire with insulation on it. Then you wrap it around the nail, and then apply a battery across the wire. A 1.5V battery probably won't have much punch so you might not be able to get much of a magnet, but a 9V battery should do it quite well. What will happen is the current flowing through the wire will create a magnetic field, which will magnetize the nail, which will create a magnet you can use to pick up coins.
A lot of the time, people run demos using special wire for creating magnets that's copper with a very thin clear insulating coating on it, so you might think you're looking at someone just making a loop of regular wire, but the insulation is key to the whole thing working.
In my experience a large 1.5v D cell works best, as the limiting factor is generally current not coil resistance, unless you wind thousands of turns of fine wire.
I'd suggest peeling off just one strand of the wire and use that. You will need to insulate the wire from the nail - Wrapping paper around the nail will do. You will need to insulate the wire from itself, so that adjacent turns don't touch. You can just space the turns out along the paper sleeve. That should do the trick. If you have twine, you can wind that on with the copper wire and use the twine to keep the turns from touching each other.
Oh to straighten copper wire, if you don't know this trick - hold your nail in a vice and wrap a single turn of copper wire around it. If you then pull on one end of the wire, keeping a little tension on the other - with a bit of practice it will give you a very straight end result, as the wire pulls away from the nail.