The word "cake" without any additional qualifiers most commonly refers to something that is large enough to be cut into slices (as in your first image); often some kind of icing/cream is involved but not always. However, "cake" can also refer to a smaller confection such as an éclair, brownie, or American "cupcake" (similar to a British "fairy cake"). An interesting example is the French madeleine, which is properly speaking a small cake but which I (an American) was raised to call a "cookie."
American "cookies" and British "biscuits" are usually bite-sized, flattish, and firmer than cake. (In British usage, chewier biscuits may also be called "cookies," whereas the term "biscuit" means something entirely different in America.) Traditional cake-like confections from non-Western countries may be called "cakes" but will usually be qualified in some way (e.g., a Malaysian "Batik cake") or be known by an entirely different name (e.g., Lebanese "sfouf").