I have a fighter character. Is there any way I can keep enemy spellcasters and archers from simply stepping 5 feet back from me and blasting me with ranged attacks or spells?
Yes, but you probably don't need to. The foe's 5-foot step keeps you from making an attack of opportunity when the opponent fires or casts a spell, but on your turn you can take a 5-foot step of your own and use the full attack action to chop the foe to bits. Alternatively, you could prepare an action to disrupt a spellcaster and you can make a 5-foot step or even a partial charge to close with the spellcaster and deliver the attack.
You can't disrupt an archer, but if you're getting tired of the step back and shoot tactic, consider using a reach weapon. That way, you'll still threaten foes 10 feet away from you. Of course, you don't threaten foes who are only 5 feet away when you're armed with most reach weapons. You can solve that problem by having an ally who can threaten the spaces adjacent to you or by gaining the Exotic Weapon Proficiency (spiked chain) feat, as the spiked chain is a reach weapon that also works against foes 5 feet away.
Also, don't forget grappling or striking the foe's weapon. Most spellcasters won't be holding a weapon, and foes holding ranged weapons don't threaten you, so you don't have to worry about triggering an attack of opportunity when using either tactic. Foes you've grappled can't step away from you until they escape your hold. Striking a foe's weapon is often less troublesome, and if you break it, you won't need to worry about ranged attacks. Normally you need to make an opposed attack roll to strike a foe's weapon or shield, but if the item you're striking is not a melee weapon or a shield, just use the rules for striking a held, carried, or worn object (pages 135 and 136 in the Player's Handbook). Again, you'd normally trigger an attack of opportunity for striking the foe's equipment, but a foe armed with a ranged weapon doesn't threaten you.
This can be a very effective tactic against opponents armed with bows. A longbow, composite longbow, or heavy crossbow has an Armor Class of 14 (base 10, -1 for size, +5 for being a held object) plus the wielder's Dexterity bonus and whatever deflection bonus the wielder might have, which makes it a fairly easy target. A shortbow, short composite bow, light crossbow, or repeating crossbow has an Armor Class of 15, which is same as a longbow, but they no size adjustment because these weapons are Medium-size. Bows have hardness 5 and 2 hit points (just like spears), crossbows are tougher (hardness 10, 5 hit points). If you have multiple attacks, it's usually best to aim your attacks with the highest attack bonuses at the opponent and save your later attacks with lower attack bonuses for the weapon. Often, you'll have difficulty hitting the opponent with these attacks, but you'll find the weapon an easier target.
You also could do the following: Ready an action so that when the archer steps away from you, you make a partial charge against him or just a 5-foot step and an attack). When you've finished your attack, he's within your reach and you'll get an attack of opportunity against him if he tries to shoot. The higher level you are, however, the worse the trade-off between taking a single attack with a prepared action and taking the full attack action.