One way to achieve this would be to:
1. Link the two tables together
2. In Table A, create a "Count" field to count the number of linked records
3. Create a "Formula" field to check whether the "Count" field matches the value of the "Quantity" field
4. Create an automation that will trigger when the "Count" field is updated or the "Quantity" field is updated
- Add a conditional step that will check whether the formula field from step 3 passes the check
5. Add a "Create record" step that will create a new record and link it to the triggering record
Here's a base with the above setup for your reference
My automation helpers scripts includes a script for generating a list from a number.
You can then use that list in a repeating group. Put your Create record action inside the repeating group.
This method will use only one automation run to create all of the linked records. It also does not require any additional helper fields.
I wrote up an explanation with screen captures here.
Note that automations can have limited advanced logic. If your automation already has a repeating group or conditional logic, you will not be able to add a new repeating group.