Your confusion seems to originate in how you create characters that are above level 1 when starting.
The players' handbook doesn't have a way to create characters that start above level 1, other than creating a level 1 character, and then leveling him up to the appropriate level.
Let's take the level 3 bard as an example.
When you create your level 3 bard, you start out with building a level 1 bard. He has 4 level 1 spells, chosen from the bard spell list. When he reaches level 2, he gains another spell known, and can exchange 1 known spell for another one. He now knows 5 level 1 spells. When he reaches level 3, he gains another known spell, along with 2nd level spell slots. He can also exchange one known spell for another one. He now knows 6 spells, and up to 2 of them can be second level.
For your character generator, I recommend either only doing first level characters, or doing first level characters you can then level up. This is most intuitive for you to program, and doesn't overwhelm the users with too many options immediately.
- Is spells known affected by ability score modifier per level?
No, they are not, not for prepared or spontaneous casters. The only time ability scores come into play is with the starting spellbook/familiar for 1st-level wizards, witches, and the like. And yes, that uses the character’s Intelligence (or Constitution in your case) at the time the first level of wizard or witch or whatever is taken, and you do not retroactively gain new 1st-level spells when your Intelligence (Constitution) goes up.
Note that prepared spellcasters with a spellbook/familiar can also just buy additional spells known. They are not limited by their class features the way spontaneous spellcasters are (spontaneous casters can buy pages of spell knowledge but those are very expensive).
- Is favoured class that grants +1 spell per level increasing the base spells learnt per level to 3?
Yes, it is. You understand this correctly. That sort of favored class bonus is far more valuable for spontaneous spellcasters; you may actually prefer hp or skill points. Also, since you must select spells of a level below the highest you can cast, and you start with all cantrips already available to you, this favored class bonus cannot be used until 3rd level, when you get 2nd-level spells and can thus choose 1st-level spells with this feature.
- Is bonus spells per day affected by ability score at different levels or only at the current level?
Your ability score as it is at the time you prepare spells each day. Some fleeting temporary bonuses or penalties don’t count, but other than that, you just determine your bonus spells each time you prepare spells based on your Intelligence (Constitution) at the time.
- Are patron spells completely separate from spells known per level?
Yes, they are, they do not count towards those you learn normally.
PHB p. 114, under the Preparing and Casting Spells heading. 2nd paragraph, 2nd sentence
If you're asking about how many spells they should have in their spell book, also on p.114, Under the heading Spellbook at the top of the page,
and at the bottom of the page under Learning Spells of 1st level and Higher,
So, assuming you have a 16 Int, a third level Wizard can prepare 6 spells (3 int mod + 3 level), and your spellbook should contain 10 spells, probably 8 1st level and 2 2nd level.