How can the battery get discharged while Ampere is showing that it is charging?
As said in the comments, the issue is that Ampere doesn't take into account the battery consumption when showing the charging current.
Example:
AccuBattery, which takes into account the battery consumption when showing the charging current:

Ampere: