Technically, you don't need a forge to temper something. I know professionals who use a torch for tempering, since it's much more precise than a forge. Most spikes are mild steel which will not make good blade edges, on the head should be an HC or HCS, which stands for high carbon steel and has twice the amount of carbon as mild steel- but it's still a lower grade than 1060 steel (which is typically the lowest grade for knives) from my experience. Those spikes are used in high stress areas, curves, switches, that sort of thing. It can hold an edge, but you have to adjust the bevel to the hardness of the steel. The harder the steel, the sharper the bevel angle can be (it really depends what your knife will be used for).
Rails still connected to the railroad don't make good anvils because of the spring, but it's better than nothing. Just make sure you have a lookout if you do that, you might not hear a train coming with all that hammering. A foot long piece anchored into a tree stump won't have that spring, since the wood will absorb the shock. You can find rail pieces where they cut a new rail to fit one that has worn out/been damaged. They can only be used for small works though.