you meant to tell me that both original and replacement batteries are faulty, after apple support's battery diagnosis gave a pass?
Yes, the original battery was not performing optimally due to having gone through too many charge cycles within the year of you having the phone. It's not a "failure" of the battery as such. It's a systematic degradation but is propelled when you charge your phone too often up to 100%. Such issues don't get caught in the diagnostics Apple have. In fact no diagnostic test can catch such issues at present. It happened to mine as well and that's why I got it replaced even though Apple kept saying it's fine based on their diagnostic results.
Your replacement battery is faulty inherently, that's why the phone is behaving abnormally. Chances of such occurrence with original battery is almost none and even if it does happen by chance, Apple will replace it again free of charge.