The answer depends on whether you want accuracy with respect to original (national) sources, more comparability, and how much time you want to spend compiling data.
If you want to focus on a very few countries, or even just one country, I suggest to always go to the primary source, which is the national statistical office, or central bank (depending on the country). There you will have ample documentation about what is being measured. Albeit countries are urged to use the latest UN System of National Accounts, there might be particular issues that are nation-specific, which you will find in the national documentation. Additionally, you will find references to GDP measured in different ways (output, income, or expenditure approaches), which do not always give the same result.
To compare a few countries, you can use primary sources and then decide yourself how to compare them. For example, you can compare growth rates, transform GDP into an index (e.g. GDP=100 in 1990), or into a common currency, where you can decide which exchange rate to use.
This approach on primary sources gives you more accuracy with respect to national data, and also greater transparency in what you are actually measuring or comparing.
Now, if you want to compare many countries, or entire regions (e.g. OECD, EU, NAFTA, etc), using a consistent definition, or perhaps have little time for this comparative exercise, it might be better to use some international database like World Bank or Penn Tables. Here, you depend on the particular arrangements of each institutions (in terms of assumptions regarding exchange rates, price indexes, etc).
For example, the World Bank data states its source as World Bank national accounts data, and OECD National Accounts data files. And yet, it indicates some limitations of the calculations:
Limitations and Exceptions: Gross domestic product (GDP), though widely tracked, may not always be the most relevant summary of aggregated economic performance for all economies, especially when production occurs at the expense of consuming capital stock. While GDP estimates based on the production approach are generally more reliable than estimates compiled from the income or expenditure side, different countries use different definitions, methods, and reporting standards. World Bank staff review the quality of national accounts data and sometimes make adjustments to improve consistency with international guidelines. Nevertheless, significant discrepancies remain between international standards and actual practice. Many statistical offices, especially those in developing countries, face severe limitations in the resources, time, training, and budgets required to produce reliable and comprehensive series of national accounts statistics. Among the difficulties faced by compilers of national accounts is the extent of unreported economic activity in the informal or secondary economy. In developing countries a large share of agricultural output is either not exchanged (because it is consumed within the household) or not exchanged for money.
The Penn Tables are also based on national accounts. As the Documentation states:
One of the major inputs into PWT is National Accounts (NA) data on gross domestic product (GDP) at current and constant prices, in local currency units. [...] We primarily source these data from the UN National Accounts Main Aggregates Database,
There are difference between these two sources. On the one hand, the WB database offer data in local currency units and US dollars (either in current or constant prices), and also in PPP. Additionally, the WB dataset includes all the exchange rates used to calculate its series. Penn Tables only include data in constant USD and PPP.
On the other hand, Penn Tables include data on PPP GDP measured in terms of output and expenditures. With WB, it is not clear which they are using for each country. Additionally, Penn Tables data is usually longer (some series start in 1950).
To check consistency across these databases, I made a few comparisons between the WB and Penn Tables data, for constant USD dollars, and for all countries I tried (France, India, Brazil, Canada), the correlation between the two series was 0.999). So clearly, there might not be much of an issue which one you use (as long as the one you want is available).
Finally, regarding IMF, I would not use these. Their comparative advantage is not to be a database of GDP statistics but of financial and government variables. Its database is not intuitive to use, and GDP documentation is in my opinion of low quality. If you want other alternatives to the above two, you can check UN stats, OECD, Eurostat, or other regional bodies. Finally, you can also use FRED.
(there are other benefits of Penn Tables, not related to GDP itself, which is that you can compare components of GDP (e.g. investment, government spending, etc) or TFP in a consistent fashion across countries)
For single or few country analysis, use primary source (national statistic office or central bank offices). For comparative analysis across many countries or macro-regions, the World Bank is the most comprehensive database. Penn Tables include just a few definitions of GDP. In any case, for common definitions, the two datasets are practically identical.