about acceleration

hello guys. Im really new to unity tho so theres still lots of things I cant really understand well. I am making a game like such a ball keep bouncing inside a big square walls and the ball will keep accelerating. I can make the ball accelerate in a specific direction by AddForce but if the ball has changed direction due to bouncing, the direction of acceleration will still remain, which mean the ball will not accelerate in the velocity direction. I want the ball to accelerate in the current velocity direction, what code should I write?
I have tried using lastpos-currentpos method to store the direction but somehow i stuck due to lack of knowledge of programming, or is there other way to achieve that?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bouncyscript : MonoBehaviour
{public Rigidbody2D rb;
public float force;

// Start is called before the first frame update
void Start()
{
rb.AddForce(new Vector2(force, force));

}

// Update is called once per frame
void Update()
{

}
private void FixedUpdate()
{

{
// currpos = transform.position;
// if (lastpos != currpos)
// newpos = currpos - lastpos;
//lastpos = newpos;

// rb.AddForce(new Vector3(accenewtemp.x, accenewtemp.y, 0));
}
}

You can get the velocity out of the Rigidbody or Rigidbody2D.

That is a Vector and any Vector will have a .normalize property on it.

This returns an equivalently-facing Vector that is precisely 1.0 units long.

If you take velocity, normalize it, then multiply it by something (i.e, your desired speed to maintain), you can use that to re-set the speed and thus confidently continue going a particular speed in any given direction, without actually changing that direction from this speed enforcement step.

can you give me a sample code on how to do this? I never learn about normalize before and not really sure how to use it.
Btw,this time, what i want to do is
When the ball collide with the square, it increse in speed. i had achieve this using another method like this

public class bouncyscript : MonoBehaviour
{
public Rigidbody2D rb;
float force=200f;
public float acce;
public Transform ballpos;
Vector3 lastpos;
Vector3 direction;

private void Awake()
{
lastpos = ballpos.position;
}
void Start()
{
rb.AddForce(new Vector2(force, force));

}

void Update()
{
Vector3 currpos = ballpos.position;
lastpos = currpos;

}

void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == “rocket”)
{

direction =ballpos.position - lastpos;
rb.AddForce(new Vector2(direction.xacce, direction.yacce));
Destroy(collision.gameObject);
}

this increasethe velocity of ball once it collide with rocket tagged square, but I dont know why it works. Whats the theory behind? in the OnCollision function, why would the ballpos.position is not the same as lastpos?