Although scale has never exactly been a deep concern when it comes to Transformers, given that the series has featured F-15 jets not much larger than sports cars, it is not uncommon for certain Transformers to clearly and deliberately change size when transforming from one mode to the next. The methods employed for this startling alteration in physicality have differed from timeline to timeline, and have long been a heavily debated aspect of Cybertronian technology.
Note that many of the Transformers named here have also transformed at certain times without shrinking or enlarging, retaining an alternate mode to scale with their robot mode.
The most famous examples of size-changing Transformers are Megatron, who becomes a pistol, and Soundwave, who becomes a stereo cassette player. These two Decepticons shrink as they transform, assuming one of two sizes – one that allows another Transformer to wield or operate them, and another, even smaller size, to scale with humans. Other shrinking Transformers include Reflector, Blaster, Mini-Cassettes, Perceptor and Trypticon.
Conversely, Transformers have been known to grow in size when assuming their altmodes — the most prominent example is surely Astrotrain, whose space shuttle mode could become large enough to convey a whole contingent of Decepticon warriors, and even allow Devastator to form inside him. Other Transformers that enlarge in such a manner also generally do so for the purposes of transporting others; they include Omega Supreme, Skyfire and Cosmos. Combiners are often larger in their combined form than their robot modes would otherwise indicate - in fact, in the episode Chaos, Predaking is explicitly shown to enlarge after his combination is complete. In the original animated series many of the Transformers arguably enlarged or shrank in vehicle mode to a lesser extent, this is most notable among groups such as the Decepticon jets and minibots, whose altmodes could not possibly turn into robots that are the size they are depicted otherwise. Whether this was truly intended to indicate actual size changes, was merely "lazy animation", or was simply a stylistic choice designed to emphasise the awesome stature of robot-mode Cybertronians, is a matter of individual opinion.
Implicit size changing
Transformers that act as transport for other Transformers often implicitly change size to do so. However, size changing is rarely explicitly depicted in these cases. Instead, the following method is used: A character such as Astrotrain transforms in-frame from robot to shuttle with no visible expansion of size relative to his surroundings. Cut. In the following shot his fellow Decepticons are shown running into frame, suddenly relatively tiny in stature so that they can board the shuttle. Although Astrotrain has not been shown to actually grow, one has to infer that this is more likely than that all his confederates have individually shrunk.
The same change-in-scale-via-implicit-size-changing is used with Omega Supreme and other characters used as transport. For example, in the episode "Make Tracks", Hoist, who is depicted as one of the larger Autobots in robot mode, is shown riding inside Huffer, a Minibot whose truck mode is usually depicted as being smaller than Optimus Prime's. So either Huffer is extremely large in that scene, or Hoist is suddenly the size of a human.
(The other explanation is that the animators simply hoped no one would notice the sudden change in scale. Since Transformers is usually targeted at kids, there's probably some truth to this.)
Although the original American cartoon did not feature any Pretenders, the Japanese-only continuity did, in their series Super-God Masterforce. Here the Pretenders did not have outer shells so much as ill-defined holistic transformations which explicitly involved size-changing, allowing the Autobots to convincingly pass themselves off as humans. Also, Autobot Pretenders' shells are able to perform size changing in the Super-God Masterforce manga. The Decepticons, by comparison, chose to retain their gigantic proportions when in Pretender-mode.
Although never depicted in any of their actual fiction, Dreamwave's More Than Meets The Eye encyclopedia stated that Pretender shells use shrinking technology to achieve the Masterforce-like capacity to pass the wearer off as a real human (or other small lifeform of choice). (Intriguingly, the profile also obliquely implies that Pretender technology would later lead to the development of the quasi-organic beast modes of the Beast Era.)
Although size-changing has been evident in Transformers from the very beginning, the original animated series and comic books never address the topic, and it was regarded as simply being the way of things. Fandom debate on the topic has seemingly inspired later fiction to offer varying explanations on how it functions.
Dreamwave offered two explanations for size-changing within its continuity.
The first, to explain enlarging, was parts compression – the notion that the Transformers in question, such as Astrotrain and Broadside, had many dense layers of armor in robot mode, which then slid out, expanding to create a much larger, but less-strongly-armored vehicle mode. Fans have referred to this as the "origami Transformers" explanation, and it appeared in their More Than Meets The Eye encyclopedia.
The second explanation, to justify shrinking, was mass conversion. This method put it that Transformers like Soundwave were intrinsically endowed with the ability to transform not simply their bodies, but their entire molecular structure. This ability, not under their conscious control, only activates when they transform, shifting their atoms according to a pre-determined schematic.
IDW's Escalation sees Megatron employ a mass-displacement sequence, physically discarding a portion of his bodily mass to allow himself to shrink to a human-scaled pistol of appropriate weight and density. What with E equalling mc², the loss of this amount of mass (shunted to an undisclosed location in space and time) results in a volatile energy discharge, requiring bystanders to step away lest they be injured by the forces released - not that Megatron would care.
Due to the energy shortage (and seeming near-total depletion of Transformers' primary fuel source, Energon) caused by their war, mass displacement hasn't been commonplace for a very long time. Since it requires a huge amount of energy, the technology had practically vanished until the discovery of Ore-13 on Earth.
The creators of the 2007 live-action movie explicitly avoided including any Transformers who could change size, on their own, wishing to avoid the necessary suspension of disbelief. Therefore, any observed scale problems are genuine scale problems. And there are a few, most notably human-sized Frenzy's head turning into a tiny cell phone (although the writers seem to be using the 'origami' explanation for that one). That said, size-changing technology clearly exists in some form in the movie continuity, as Bumblebee somehow shrinks the All Spark down to a manageable size and mass. Thus far, there's no evidence this trick can be applied to anything except the All Spark. (Well... not everybody think so.)
In Transformers Animated, for possibly the same reason, none of the characters seem to change size much other than Jetfire and Jetstorm, who change from normal sized (or slightly bigger than some) to big enough to carry Sentinel Prime. Prowl's alt mode is quite small and yet he's taller than Bumblebee in humanoid mode (this is likely to be a genuine scale issue).
The issue of shrinking and enlarging was, in the early days of the online Transformers fandom, a frequently debated subject. The Transformers were clearly displacing their mass, to allow their shrunken forms to be operable – so where was that mass going? The postulated answer to this question was subspace, the void of sub-dimensional space between realities.
This explanation also served as an answer to the top Transformers question of all time ever – “Where does Optimus Prime’s trailer go when he transforms?” The answer? Subspace. Furthermore, in a few sparse instances throughout the American animated series, and with alarming frequency in the Japanese shows, Transformers’ weapons can also be seen appearing and vanishing in a flash of energy. Where are they going? Subspace. You get the idea, folks.
And if that doesn't grab you, a wizard did it...
...or nanomachines. Nanomachines can do anything.
When you see a character's size is smaller than usual, well, it's just a technical issue. In ROTF, Sam briefly explains the science behind mass-shifting. But it's really hard to understand (it's supposed to be nonsense).