The M1 MBAir was discontinued in March 2024 according to MacTracker.
Assuming this was in a factory sealed box, this laptop has been sitting for at least 19 months which is more than enough time for the battery to have completely drained & become permanently damaged. Lithium batteries must be stored with a charge level between 20% - 60% and must be periodically charged to maintain the proper charge on the battery in storage. If the battery is completely drained to 0% charge for an extended period, then permanent damage occurs to the battery.
Here is an Apple article for maintaining proper battery health......you should read the entire article, but the relevant portion for now is the section near the end of the article titled "Store it half-charged when you store it long term":
Batteries - Maximizing Performance - Apple
Otherwise, this battery may be old enough where it is starting to wear out. Generally most Lithium batteries need to be replaced between 3 - 5 years (most of it depends on how long a person needs their battery to power the laptop & the workload involved).
If the laptop is still covered by the warranty and there is no accidental damage involved, then yes it should be covered by warranty assuming the battery is really failing. FYI, Apple will only replace the battery when the Apple Diagnostics report a failure, or the Battery Condition is showing "Service Recommended".
Many times a battery draining quickly will be due to an issue with third party software. Run the third party app EtreCheck & post the complete report here so we can examine it for possible clues.
How to use the Add Text Feature When Posting an EtreCheck Report - Apple Community
It is possible you have both a damaged battery (perhaps not enough to trigger a "Service Recommended" or failing diagnostic result) and issues with third party software.