Having learned embroidery herself, Lovelace was familiar with the repetitive patterns used for handicrafts. Similarly, repetitive steps were needed for mathematical calculations. To avoid duplicating cards for repetitive actions, Lovelace used loops, nested loops, and conditional testing in her program instructions.
https://www.inverse.com/science/ada-lovelace-computing