Since QGIS 2.16 the attribute tables count the rows starting with 1, on the previous versions it started with 0, so the
$ID could match with it. Is this some kind of mistake? Do I have to use another command? Don't really understand the usefulness of this.
By "count the rows" you probably mean row lables. These does not correspond with features ID at all, they are fixed and don't affect your data - try sort table by some attribute and hover with mouse over the row lables and you will see it.
So by expression
$ID you can get exact actual id of your features starting with 0.
Note: Beware to use
$ID in virtual fields, because when you for example delete a feature, this values will set to new actual features id. For more information check this question: QGIS does not show FID field of vector data.