Hardware back goin two pages back-Capacitor and Ionic Angular

The hardware back functionality of capacitor 3 is going two page back but when running normally but in debug mode, its working fine. Why this is happening and Kindly suggest solution

Are you using @capacitor/app to listen for back button presses or handing it some other way?

Check your backbutton subscription function. It must be configured properly, Unsubscribed safely on next page navigation to work properly.
Try something like the below

backbuttonfunction=null; // Member variable to store back button function
// Your subscription logics
this.backbuttonfunction.unsubscribe(); // Unsubscribing your subscription