Why are the Shift and Caps Lock keys shaped like that ? Is it because those wide keys cannot be pressed from the ends ?
I have no idea, but I do have a PC/AT keyboard with similarly-shaped keys. They have the usual "square horseshoe" / "anti-roll bar for Matchbox cars" arrangement underneath so they don't rock when you press the end.
I think it's just what they did in the 80s.
I believe you're right. From my limited memory of that period, it was a mechanical constraint.
Keycaps tended to be molded with a hollow cylinder or stalk on their base, which fitted through a snug round aperture on the keyboard base and pressed against a spring or other restraint. Pressing the key down against the spring actuated a pcb-mounted push-switch (or bridged a pair of adjacent connectors on the pcb) that provided the keypress signal. Pressing a wide key off-centre would cause the plastic stalk to bind against the enclosing aperture. Forcing the user to press direcly above the stalk mitigates this - hence the raised part of the keycap.
There is a stack exchange question about this at [1].
As to why the shift keys were wider to begin with, I'm not sure. Perhaps a consequence of the lack of the mechanical constraints that forced typewriter keyboards into a strict grid due to the interleaving of the lever arms. Some keyboards, notably the Commodore PET, didn't use wide shift keys [2] though.
It is worth noting that keyboards in that era were machine-specific, and often hard-wired to the main system box. Afaik standardisation and interoperability didn't happen until RS232 and, later, ps2 keyboards were introduced.
[1] https://retrocomputing.stackexchange.com/questions/16471/why...
[2] and let me just say here that the PET keyboard was truly awful, even by 80s standards. Just shamefully terrible.