The general number of attacks is 1 per Attack Action. There is no formula depending on the level.
Specific rules allow this to be overwritten. For example the Fighter class gets a class feature that's called "Extra Attack" and says:
Beginning at 5th level, you can attack twice, instead of once, whenever you take the Attack action on your turn.
The number of attacks increases to three when you reach 11th level in this class and to four when you reach 20th level in this class.
Some other classes have such a class feature, too. This is how these classes get more attacks.
Another option is Two-Weapon Fighting to get a Bonus Action that is independent of your Action:
When you take the Attack action and attack with a light melee weapon that you’re holding in one hand, you can use a bonus action to attack with a different light melee weapon that you’re holding in the other hand. You don’t add your ability modifier to the damage of the bonus attack, unless that modifier is negative. If either weapon has the thrown property, you can throw the weapon, instead of making a melee attack with it.
Furthermore you can make an Opportunity Attacks to get another attack with your Reaction (not on your own turn though):
In a fight, everyone is constantly watching for a chance to strike an enemy who is fleeing or passing by. Such a strike is called an opportunity attack. You can make an opportunity attack when a hostile creature that you can see moves out of your reach. To make the opportunity attack, you use your reaction to make one melee attack against the provoking creature. The attack occurs right before the creature leaves your reach. You can avoid provoking an opportunity attack by taking the Disengage action. You also don’t provoke an opportunity attack when you teleport or when someone or something moves you without using your movement, action, or reaction. For example, you don’t provoke an opportunity attack if an explosion hurls you out of a foe’s reach or if gravity causes you to fall past an enemy.
Spells could theoretically change this, too. The spell Booming Blade, which you would cast with the Cast A Spell Action instead of the Attack Action for example says:
As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell's range, otherwise the spell fails.
In this case it would be 1 attack again, but with the Cast A Spell Action, not with the Attack Action.
The spell Haste for example targets a creature
[...] and it gains an additional action on each of its turns. That action can be used only to take the Attack (one weapon attack only), Dash, Disengage, Hide, or Use an Object action. [...]
This would give you another single weapon attack on your turn.