Sharepoint 2019 site navigation breadcrumb shows incorrect URL on application pages

I have enabled the navigation breadcrumb in the master page of my site in Sharepoint 2019. When I navigate to a library inside a sub site and verify the URL on AllItems.aspx page it shows the correct url but when I navigate to the library settings page and verify the url in the same breadcrumb it only shows the url of the parent site and does not include in the URL of the subsite and the library (incorrect URL).

This behaviour is seen on all application pages only where it shows the URL of the parent site like this
http://<parent/ top level site_url>/_layouts/15/listedit.aspx?List=%7B%7D

When we click on this link it returns an error page.

enter image description here