QGIS Field Calculator explains why outputs of area($ geometry)
and $area
are different:
area
returns the area of a geometry polygon object. Calculations are always
planimetric in the Spatial Reference System (SRS) of this geometry,
and the units of the returned area will match the units for the SRS.
This differs from the calculations performed by the $area
function,
which will perform ellipsoidal calculations based on the project's
ellipsoid and area unit settings.
EDIT: But I've noticed later that $area
function returns different results for QGIS 2 and 3. I didn't understand that you asked that. Because the question was not clear. I tried to figure out what was the reason, and dead end. I think that it's a bug as @Stu state. I've reported this issue: #34597
EDIT 2: @ndawson's answer to the bug report:
Trust the QGIS 3 results. They are much more accurate and reliable vs QGIS 2 which had some known bugs in area calculation.
$area
function.