It might be worth it to back up and ask why you are doing it this way, and what you are trying to accomplish.

This is the math (calculus) formula for acceleration. Acceleration equals the change in velocity over time, divided by the change in time.
_physics_process() handles dividing by time with the value delta, which by default divides anything you multiply it by, into 60 segments per second (because it, itself is a fraction in decimal form).
velocity.x = direction * acceleration
acceleration += 40.0
In your original code, you are saying for the first 1/60th of a second, the velocity is 40 in the direction you want to move. At 2/60th of a second, the velocity is 80. At 3/60th it is 120, and at 4/60th of a second, and as long as the player keeps moving, their velocity is 160. That change is not something a human can notice with their eyes on the screen.
In your code, technically acceleration is the change over time of velocity plotted on a curve for many physics ticks you want to measure it. Roughly:
160 _________________
120 /
80 /
40 /
If you wanted an acceleration you could visibly see, change it to something like this:
velocity.x = direction * acceleration * delta
acceleration += 1.333
acceleration = clampf(acceleration, 40.0, 160.0)
Every half second, you will get an increase of 40, and at the end of 2 seconds you’ll be going at 160. You can change the amount from 1.333 to something larger or smaller to change the rate of acceleration. Also, from a purely physics point of view, the acceleration variable should be speed.
So you could rewrite it as:
const MAX_SPEED = 160.0
const START_SPEED = 40.0
const JUMP_VELOCITY = -400.0
var speed: float = START_SPEED
func _physics_process(delta: float) -> void:
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * speed * delta
speed += 1.333
speed = clampf(acceleration, 40.0, 160.0)
else:
velocity.x = move_toward(velocity.x, 0, MAX_SPEED * delta)
speed = START_SPEED
move_and_slide()