How does know my google account?

They do that via an iframe with one of Google's beta features which is currently closed. You can see the iframe in the following screenshot of Medium's website.

Screenshot of Medium's website and Google iframe

However, this does not mean Medium will be able to access your user information. The content inside of the iframe is sandboxed and can only be accessed if Google adds a same origin policy permission permitting Medium's domain to access it. See this Medium article for more information on cross origin policies with iframes.

Web developers can integrate Google Sign-In with their website.

Google Sign-In manages the OAuth 2.0 flow and token lifecycle, simplifying your integration with Google APIs. A user always has the option to revoke access to an application at any time.

Websites can access information such as your name or email when you login. There are many ways to customize the login button or popup which is sometimes why it looks integrated to the page, while it is actually being served by Google over HTTPS. This is also why the website is able to show your name, because it is actually served by the Google API. In this specific example, an iframe is used which prevents information being shared with Medium due to the same-origin policy.