I am completely new to network engineering. So, I need some help to understand the things. I want to colocate my server with the datacenter with my own IP and ASN, do I have to have a router or a switch? As I am aware to have my IPs with my datacenter I need to have BGP peering with the datacenter/ISP. So, do I need my own hardware for this or is it handled by the datacenter? And if I need to handle this, do I new routers or switches for it?
The main reason for putting your equipment in another company's data centre is to take advantage of all the infrastructure: power, cooling, networking, physical security. Secondarily it can be advantageous if it's near something it has to communicate with a lot, such as web servers near database servers and web servers close to customers. The trade-offs between owning equipment in colocation or renting by the hour in the cloud can be complex, but I'm sure you've considered them. These are all server-related issues best dealt with elsewhere than this forum.
The main reason for having your own ASN and doing the appropriate border routing is if you have a large amount of network, with multiple peering to other networks. None of which is necessary for a few servers, and if you're new to it, it's a lot of learning and work for no particular gain. It might be helpful to read a peering guide from an exchange in Amsterdam and a peering tutorial.
I'd suggest you consider just using the networking provided by your datacentre, getting multiple redundant ethernet connections, and have your autonomy at the DNS layer.
To directly answer your question, you'd need a router, not a switch, at the border.