Q:

Does changing DNS cause problems

I have VALORANT but it shows a connection error that is resolved by changing my DNS. 
So should I change it back after playing or keep the DNS.  Will it affect other things. 
Which DNS is better: Cloudflare or Google
And also is DNS changing safe. 

A:

So should I change it back after playing or keep the DNS. 

Generally, public DNS servers are meant to provide the same kind of service as ISP-provided ones.  They'll be able to resolve the same domains and everything.  So if your ISP-provided DNS service is unreliable, you can safely keep it changed to something else. 
There are exceptions though, as mentioned below. 

Will it affect other things. 

DNS affects just about everything that uses domain names – so web browsing and most other internet usage, not just games.  For example, if the DNS server is unreliable, you might also see websites taking a long time before they even start to load. 

Which DNS is better: Cloudflare or Google

They both provide the same basic service, so it depends on your location and personal preference. 
For example, although both services use anycast to provide low latency service, in some locations the path to Cloudflare might still be several times shorter than that to Google DNS. 
Overall, though, DNS only affects the connection establishment – it doesn't affect connections once they're active.  So just use whatever feels like it's good enough. 

And also is DNS changing safe. 

Not necessarily.  Switching to a trusted DNS provider is safe, but be careful with what you choose. 
DNS services are able to able to block whatever requests they don't like, and even replace with their own data.  Sometimes they do it for benign reasons, e.g. Quad9's main servers block malware domains (they do offer a server with no blocking, too). 
Other times it's a bit questionable (e.g. OpenDNS and Level3 DNS don't simply return "no such domain", they redirect you to a page full of ads when that happens).  Some people don't like DNS servers which perform "parental" filtering. 
And of course DNS servers could be outright malicious, redirecting you to websites different from what you asked.  Fortunately even if this happens, HTTPS and TLS will protect you in most cases... but not all.