Ever wonder how an acid dissolves something or what would happen when you mix an acid with a base? Well the answer to the last question is pretty easy, mixing an acid with a base generally creates a salt. Understanding why requires some understanding that will also lend to the answer as to why acids can dissolve some things and bases dissolve others.
There are different levels of descriptions of acids and bases. Perhaps the anecdotal description of an acid is simply a substance which turns blue litmus paper red. The earliest definition of a base was first coined by Antoine Lavoisier in the 16th century. This definition was that a base is just a simple basic element such as phosphorus, carbon or sulfur. By adding oxygen to these you then get the oxidized form of each resulting in phosphoric acid, carbonic acid and sulfuric acid respectively.
A more sophisticated definition of an acid would be a substance that when added to water would give a free (positively charged) hydrogen ion into the solution and likewise a base would be something that would give an negative OH ion into the solution. Here a positive hydrogen ion is just a hydrogen atom with its electron removed (leaving just the proton) and a negative OH ion is just an oxygen bonded to a hydrogen with an extra electron.
An even more sophisticated and recent definition would be that an acid again donates a positive hydrogen ion into solution when added to water but the base this time being a substance that will absorb these hydrogen ions when added to water. This is largely because atoms try to have a neutral charge if they can at all times, no net positive or negative charge, just neutral.
Without getting into quantum mechanics, a more recent and inclusive definition of an acid is a substance that absorbs bonding electrons from other substances (with a base being something that will donate bonding electrons to other substances). Those substances which donate a positively charged hydrogen ion into a solution literally place a positively charged proton into the solution. This proton then will bounce around in the liquid until it can find a loosely bound electron on some other substance it can steal to capture and make itself neutral. In other words, the positively charged proton is going to scavenge any electrons it can find to neutralize its positive charge (because electrons are negatively charged). Any material which would have its atoms and molecules bonded together with one or more loose electron orbital’s is then a material subject to being dissolved in an acid. This because the acid will steal one of those bonding electrons and break that bond in the molecule.
Likewise, without getting into quantum mechanics, a base is something that will try to donate electrons to the solution when placed in water (with the acid wanting to absorb electrons). A negative OH ion for example has that negative charge it is looking to get rid of so it can have a net neutral charge. One rather common example of a base which does not donate a negative OH ion includes ammonia but it does have an electron orbital which is unusually loosely bound and so can give this up easily enough to be basic in nature.
Most acids do contribute a positive hydrogen ion to solution and most bases do contribute a negative OH ion to solution. Examples of these kinds of acids are hydrochloric (HCl) and sulfuric (HSO3) acid. Examples of these common bases include sodium hydroxide (NaOH) and potassium hydroxide (KOH). So when these acids and bases are placed together, they make a salt. As an example, when hydrochloric acid (HCl) and sodium hydroxide (NaOH) are mixed together (these are some of the strongest acids and bases commonly available), the resulting products are normal table salt (sodium chloride or NaCl) and water. The water comes from the positive hydrogen ion bonding with the negative OH ion to give a neutrally charged molecule of two hydrogen’s and one oxygen (i.e., water).
Common examples of other bases that follow these rules are soapy water and baking soda with concomitant common acids being vitamin C, citric juice and vinegar.