This is a form hidden with display none:

This is a label that is hidden by display:none and has a duplicate ID

This is the same form not hidden and with the same IDs as the first.

This is a label

While duplicate IDs in of themselves are no longer a failure under WCAG 2.2 ยง4.1.1, this page illustrates how duplicate IDs can lead to unexpected results. When multiple elements have the same ID, references to that ID will always pick up the first instance in the DOM. In this case the first label that is hidden by display:none will be assigned to the second form such that the visible label will not match the spoken one.