I just want to know that SEO tools like semrush , ubbersuggest , moz etc.. how do they get the data of traffic and ranked keywords of any website. Does Google provide it to them?
SEMrush (and similar tools like ahrefs, Sistrix, or Searchmetrics) have a long list of keywords. Sometimes 100 million per country.
These they query on Google and save the results. To run so many queries on Google, they employ a network of proxy servers - or similar means. Normally they will update important keywords, like "iPhone", every week, maybe even every day. And less important keywords, like "buy iPhone 6 leather case with tiger-stripes", they might only update every couple of months.
Out of this database of keywords and rankings, they can get all the rankings for any domain.
They also query the Google AdWords API (and other data sources) to obtain search volume data. Based on the ranking for a keyword and the search volume, they calculate the estimated traffic each domain gets per keyword. This they aggregate into a value like SEO Traffic or SEO Visibility across all keywords.
Important: the traffic numbers are just estimations. For a large site like Booking or eBay, the insights from SEMrush and similar tools are normally reliable. But for a very small site, on a site in a very specific niche, these keyword tracking tools are sometimes way off.