◆Offset
The deviation of the first transition (0x000 to 0x001) compared to the ideal transition (at 0.5 LSB). Ideal value: 0 LSB.
0>1に変化する理想の場所は0.5LSBの位置と有るのでこの説明だと量子化補正の有る理想ADCとの比較が前提となってる

◆Gain error:
After adjusting for offset, the gain error is found as the deviation of the last transition (0x3FE to0x3FF) compared to the ideal transition (at 1.5 LSB below maximum). Ideal value: 0 LSB
1022>1023に変化する理想の位置は最大値(VREF)から-1.5LSBの位置と有るので量子化補正の有る理想ADCとの比較が前提となってる

データシート読むとゲインエラーはオフセット補償をした後の値と有るので

Arduino(UNO)はこれが正解じゃないだろうか・・・
Vin = ( ADC + Offset ) * Vref / ( 1024 + Offset + ( Offset - Gain error ) )
Vin = ( ADC + 2 ) * Vref / ( 1024 + 2 + 2 - 2 )
Vin = ( ADC + 2 ) * Vref / 1026
(※オフセット・ゲインエラーはデータシートの標準値を適応)

参考資料
ATmega48A/PA/88A/PA/168A/PA/328/P(Data Sheet)
AVR120: Characterization and Calibration of the ADC on an AVR (APPLICATION NOTE)
AVR127: Understanding ADC Parameters (APPLICATION NOTE)