In addition to increasing your ability score beyond 20 (see ravery's answer), some classes can gain benefit from choosing the Magic Initiate feat (unfortunately, RAW, not those classes you specified in the question).
The feat states:
Choose a class: bard, cleric, druid, sorcerer, warlock, or wizard. [...] In addition, choose one 1st-level spell from that same list. You learn that spell and can cast it at its lowest level. [...]
Per the Sage Advice Compendium, you can pick Magic Initiate for a class you already have and you can also use spell slots to cast the spell you gain more often, effectively giving you an additional 1st-level spell that you have always prepared.
If you’re a spellcaster, can you pick your own class when you gain the Magic Initiate feat?
Yes, the feat doesn’t say you can’t. For example, if you’re a wizard and gain the Magic Initiate feat, you can choose wizard and thereby learn two more wizard cantrips and another 1st-level wizard spell.
If you have spell slots, can you use them to cast the 1stlevel spell you learn with the Magic Initiate feat?
Yes, but only if the class you pick for the feat is one of your classes. For example, if you pick sorcerer and you are a sorcerer, the Spellcasting feature for that class tells you that you can use your spell slots to cast the sorcerer spells you know, so you can use your spell slots to cast the 1st-level sorcerer spell you learn from Magic Initiate. Similarly, if you are a wizard and pick that class for the feat, you learn a 1st-level wizard spell, which you could add to your spellbook and subsequently prepare.
In short, you must follow your character’s normal spellcasting rules, which determine whether you can expend spell slots on the 1st-level spell you learn from Magic Initiate.
Clearly, this allows classes that have all of their spells prepared (such as Sorcerers or Warlocks) to expand their daily available spell list.
Wizards are explicitly called out to require adding the spell to their spellbook, so (unless you houserule) they won't benefit beyond additional cantrips and getting a free casting once a day.
Druids or Clerics, however, don't have a spellbook and can already choose from all of their class spells when preparing. The rules are, therefore, unclear on whether they can count the spell gained from Magic Initiate as "always prepared". Judging by how Wizards have to prepare the spell, I believe an official rule would lean towards disallowing this.
Personally, I would houserule that the spell gained from Magic Initiate counts as an always-prepared spell, to avoid discrepancies between classes that have all spells prepared (e.g. Warlocks) and those that have to choose (e.g. Wizards or Druids). Especially Druids or Clerics would gain nothing, because - unlike Wizards - they wouldn't even benefit from an expanded spelllist.
You'd obviously have to talk about such a houserule with your DM, though.
Either way, Magic Initiate allows you to cast a 1st-level spell once a day for free, regardless of whether it's prepared or not. So, as long as you don't need the spell more than once a day (for example, choosing Alarm and casting it once a night), it's effectively an always-prepared spell.
If you're either a Cleric or Druid, you can multiclass one level into the other class to gain a massive increase in prepared spells - in fact, you gain an additional number of prepared spells equal to your WIS modifier. Since the respective spell lists overlap in many cases, you can probably choose most of the 1st-level spells you want to prepare from the lower-level class's spell list, and choose the higher-level ones from your main class's list. Note that, technically speaking, you have to differentiate between both classes in terms of preparing, i.e. you can't prepare cleric spells with your druid "preparation slots". Therefore, you can only use the secondary class for low-level spells.
Unfortunately, this trick isn't as convenient if you're a wizard, since there is currently no other class that uses INT for spellcasting purposes (although this opportunity might come up if or once the Artificer or Mystic classes transfer from Unearthed Arcana to an official rulebook).
Multiclassing into a tertiary caster (such as Eldritch Knight or Arcane Trickster) is not viable, since they learn at most as many spells as their level - and every level you multiclass is substracted from the maximum number of Wizard spells you can prepare. In fact, multiclassing more than 4 levels into one of those classes will actually reduce your number of spells.
You can, of course, still multiclass into non-INT-casting classes to gain more prepared spells, but you'll then have two different spellcasting modifiers, which will mean the spells of the secondary class are weaker than those of your primary class.
The PHB states on page 164 on multiclassing:
You determine what spells you know and can prepare for each class individually, as if you were a single-classed member of that class.
Boons, as detailed in the DMG on page 232, can allow you to (sort of) increase your number of prepared spells. Namely, the Boon of Spell Mastery, Boon of Spell Recall, Boon of Dimensional Travel, Boon of the Fire Soul and Boon of the Stormborn allow you to cast certain spells for free.
Boon of Spell Mastery:
Choose one 1st-level sorcerer, warlock, or wizard spell that you can cast. You can now cast that spell at its lowest level without expending a spell slot.
Boon of Spell Recall:
You can cast any spell you know or have prepared without expending a spell slot. Once you do so, you can't use this boon again until you finish a long rest.
The other boons allow you to cast the spells Misty Step, Burning Hands and Thunderwave once per short rest or at will (depending on the boon).