Well, whether these products are liquids or solids typically has more to do with the additional ingredients than the actual cleansing agent.
Soap, chemically speaking, is a surfactant composed of the salt of a fatty acid, typically lauric, palmitic or stearic acids. It's typically produced by adding a strong hydroxide base to liquefied plant or animal fat, which liberates the fatty acids from the triglyceride via hydrolyzation, where they then bind with the free cations from the base forming an amalgam of salts.
Shampoo, or more specifically the detergents present in it, are similar, but produced by a different process, to create a surfactant that is less likely to bond to the mineral compounds in hard water, and so is more effective than soap when using it with tap water from most regions. Sodium lauryl sulfate and sodium laureth sulfate are the two frontrunners here; the former is very powerful, and doesn't foam as much, so it's typically used for laundry detergent. The latter is gentler on human skin (less irritating) and so is typically used for various hand and body cleansers including shampoos. The two split about 50-50 in dish soaps, with a third surfactant, lauramine oxide, also making an appearance as a heavy-hitting degreaser.
Both of these substances act in a similar way; they have a hydrophilic (water-attracting) side, and a hydrophobic (water-repelling) side. When dissolved in water (which happens slowly unless the surfactants are already dissolved), the hydrophobic side is attracted to anything that isn't water, and so it will loosely bind via various van der Waals forces to mineral compounds and organics such as those found in dirt, grease, grass stains, oil, lipstick etc. These molecules end up surrounding small particles of these substances on all sides in a bid to "shelter" their hydrophobic end, forming a "micelle". The hydrophilic side exposed to the water, then, allows the micelle to float away in the water and resists the substance in the core of the micelle reattaching to the surface it had been on (dishes, clothes, skin, hair etc), so it can be easily rinsed away.
Now, the form in which a detergent is most useful typically determines whether its sold or packaged as a liquid or solid. Overall, its state is most directly determined by the amount of water in the product. If you've ever had a housemate that never wipes off or closes the nozzle on a bottle of dish detergent, you will have learned that these "liquid" soaps don't have much trouble being solid, either. The liquid products sometimes have an alcohol that helps keep the water from evaporating (and some, like cetyl alcohol, are what make certain products opaque as well as thickening them to give the appearance of a cream), but if marketing wants the product to be a solid, all the chem-engineers have to do is run the mix through a warm (160-250*F) oven to evaporate excess water, leaving behind a pliable solid that can be pressed into bars or minced into soap flakes such as for laundry powders. As far as efficacy in any given form, as I said, liquids tend to disperse in wash water more easily than solids (which is good in the case of a bar soap, not do good with a dishwasher or laundry detergent), though the powder forms are designed to dissolve well, usually through use of some sort of "filler" that spaces out the active ingredients and dissolves easily (and also allows for "everyday" units of measure, so it feels like you're adding enough soap to the water to get your clothes or dishes clean, when in reality a tablespoon of the concentrated active ingredients is more than enough as evidenced by the little gel packs).